--01 - parameter types
	DECLARE @ConfigurationParameterTypes TABLE (Id int NOT NULL,Title nvarchar(max) NOT NULL);


	INSERT into @ConfigurationParameterTypes (Id, Title) VALUES (86, N'AtHomeForTooLong')


	SET IDENTITY_INSERT dbo.ConfigurationParameterTypes ON

	MERGE INTO dbo.ConfigurationParameterTypes AS TARGET  
		USING @ConfigurationParameterTypes AS SOURCE  
		ON TARGET.Id = SOURCE.Id
		WHEN MATCHED THEN    
			UPDATE SET Title = SOURCE.Title
		WHEN NOT MATCHED BY TARGET THEN   
			INSERT (Id, Title) VALUES (SOURCE.Id, SOURCE.Title)  
	OUTPUT $action, SOURCE.*;

	SET IDENTITY_INSERT dbo.ConfigurationParameterTypes OFF


-- 02 - add the parameter to all entitytype "RulePolicyRuleType" = 12
insert into ConfigurationGroupParameters ( GroupId,ParameterId,Value) 
select groupid,86 parameterid,'1' value
  from ConfigurationEntityTree g1
  where EntityTypeId in (12)
	and 0 = (select count(1) from ConfigurationGroupParameters g2 where g1.GroupId=g2.GroupId and ParameterId=86)