Reputation: 41
My UDF's body has the following HAVING class.
HAVING
Company.Description = @Company AND
SystemCustomerType.Description = @CustomerType
I tried to call this by this following syntax.
SELECT * FROM FunctionName('ABC_Company',NULL)
And also tried to set default value as NULL
for @CustomerType
parameter. And called the function by
SELECT * FROM FunctionName('ABC_Company',default)
Upvotes: 0
Views: 1102
Reputation: 850
'something' = NULL always returns false. To check if something is NULL use 'is'.
HAVING
Company.Description = @Company AND
(SystemCustomerType.Description = @CustomerType
or (SystemCustomerType.Description is null and @CustomerType is null))
Upvotes: 0
Reputation: 11205
Try this:
where (Company.Description = @Company or @Company is null)
and (SystemCustomerType.Description = @CustomerType or @CustomerType is null)
Then use:
select * from FunctionName('ABC_Company',NULL)
Upvotes: 3
Reputation: 10875
you can use NULL as parameter and then:
HAVING
Company.Description = @Company AND
SystemCustomerType.Description = isnull(@CustomerType,'')
provided you don't need to differenciate between NULL and empty string
Upvotes: 0