Please tell me what I am missing in this example.
I have a stored procedure where I provide a default value of an empty string for a parameter. When I check the value, it comes back as NULL. I'm not sure if the default value is not being applied, or my ISNULL check is wrong.
Here is a simple example to illustrate:
CREATE PROCEDURE TestDefaultValueParam
@vcTestName varchar(100)= ''
AS
BEGIN
IF ISNULL(@vcTestName, '') = ''
BEGIN
PRINT '@vcTestName IS NULL'
END
ELSE
BEGIN
PRINT '@vcTestName NOT NULL'
END
END
I have tried the following 3 commands:
EXEC [dbo].[TestDefaultValueParam] @vcTestName = NULL
EXEC [dbo].[TestDefaultValueParam] @vcTestName = ''
EXEC [dbo].[TestDefaultValueParam]
The result was @vcTestName IS NULL for all three even though there is a default empty string provided in the stored procedure.