
  --add new default system parameter
	DECLARE @SystemParameters TABLE 
		(
			[InstanceName] [nvarchar](50) NOT NULL,
			[InstanceIdentifier] [nvarchar](50) NOT NULL,
			[ParameterKey] [nvarchar](100) NOT NULL,
			[ParameterDesc] [nvarchar](500) NOT NULL,
			[Value] [nvarchar](max) NOT NULL,
			[DataType] [nvarchar](20) NOT NULL,
			[AllowDelete] [bit] NOT NULL
		);

	INSERT @SystemParameters ([InstanceName],[InstanceIdentifier],[ParameterKey],[ParameterDesc],[Value],[DataType],[AllowDelete]) 	
	VALUES ('EpaParameters', 'default', 'EpaNotWornDurationTriggerEventInHours', 'The number of non worn hours that trigger EPA non compliance event', '24', 'System.Int', 0)

	INSERT @SystemParameters ([InstanceName],[InstanceIdentifier],[ParameterKey],[ParameterDesc],[Value],[DataType],[AllowDelete]) 	
	VALUES ('EpaParameters', '2', 'EpaNotWornDurationTriggerEventInHours', 'The number of non worn hours that trigger EPA non compliance event', '24', 'System.Int', 0)

	INSERT @SystemParameters ([InstanceName],[InstanceIdentifier],[ParameterKey],[ParameterDesc],[Value],[DataType],[AllowDelete]) 	
	VALUES ('EpaParameters', 'default', 'EpaNotWornTriggerEventMinimumLevel', 'The minimum number of non worn hours that trigger EPA non compliance event', '8', 'System.Int', 0)

	INSERT @SystemParameters ([InstanceName],[InstanceIdentifier],[ParameterKey],[ParameterDesc],[Value],[DataType],[AllowDelete]) 	
	VALUES ('EpaParameters', 'default', 'ComplianceAlertFeatureEnabled', 'Is the compliance feature enabled', 'False', 'System.Boolean', 0)

	INSERT @SystemParameters ([InstanceName],[InstanceIdentifier],[ParameterKey],[ParameterDesc],[Value],[DataType],[AllowDelete]) 	
	VALUES ('EpaParameters', '2', 'ComplianceAlertFeatureEnabled', 'Is the compliance feature enabled', 'False', 'System.Boolean', 0)

	MERGE INTO [dbo].[SystemParameters] AS TARGET
	USING @SystemParameters AS SOURCE
	ON		SOURCE.InstanceName = TARGET.InstanceName AND 
			SOURCE.InstanceIdentifier = TARGET.InstanceIdentifier AND 
			SOURCE.ParameterKey = TARGET.ParameterKey
	WHEN NOT MATCHED BY TARGET THEN
		INSERT (InstanceName,InstanceIdentifier,ParameterKey,ParameterDesc,Value,DataType,AllowDelete)
		VALUES (SOURCE.InstanceName,SOURCE.InstanceIdentifier,SOURCE.ParameterKey,SOURCE.ParameterDesc,SOURCE.Value,SOURCE.DataType,SOURCE.AllowDelete);
	--WHEN MATCHED THEN
	--	UPDATE SET  InstanceName = SOURCE.InstanceName,
	--				InstanceIdentifier =SOURCE.InstanceIdentifier,
	--				ParameterKey = SOURCE.ParameterKey,
	--				ParameterDesc = SOURCE.ParameterDesc,
	--				Value = SOURCE.Value,
	--				DataType = SOURCE.DataType,
	--				AllowDelete = SOURCE.AllowDelete;