Unanswered: '@NumericVal IS NOT NULL' seems not to return a boolean.
I'm trying to ensure that only of the parameters is passed to my stored procedure.
BOL says that the IS [NOT] NULL operator (language construct?) will return a boolean. An IF statement takes an expression which results in a boolean so I was surprised to find that the below code doesn't parse.
CREATE PROC sp_OneParm(
@NumericVal float = null,
@StringVal nvarchar(200) = null,
@DateVal datetime = null,
@BitVal bit = null)
DECLARE @ValCount tinyint
SET @ValCount = 0
-- Ensure we've only got one update value specified
IF @NumericVal IS NOT NULL @ValCount = @ValCount + 1
IF @StringVal IS NOT NULL @ValCount = @ValCount + 1
IF @DateVal IS NOT NULL @ValCount = @ValCount + 1
IF @BitVal IS NOT NULL @ValCount = @ValCount + 1
IF @ValCount > 1 RAISERROR ('Only one @*Val paramater may be specified when calling sp_OneParm()', 16, 1)
-- Other Stuff
Am I missing something simple or do I need to restructure my code to achieve the logic I want?