-- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- This block of comments will not be included in -- the definition of the function. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE FUNCTION NonNullAiAj ( -- Add the parameters for the function here @attributeName1 varchar(50), @attributeName2 varchar(50) ) RETURNS INT AS BEGIN DECLARE @NonNullAiAj INT; -- Add the SELECT statement with parameter references here SELECT @NonNullAiAj = COUNT(distinct a1.idEvent) FROM dbo.CorrelationAttributes as a1 WHERE (a1.attribute = @attributeName1 OR a1.attribute = @attributeName2) and a1.value is not null and not a1.value=''; RETURN @NonNullAiAj; END; GO