October 16, 2019 at 5:26 pm
i have a variable called date
@Date DATETIME = NULL,
i want to capture this variable into error log information
set @log = @Log + ' ,Date: ' + @Date
but this is not capturing anything.
i have tried convert(varchar(20),ISNULL(@Date,GETDATE()),110) it worked ; but i don't want to capture getdate. i want to print NULL.
October 16, 2019 at 5:36 pm
Use coalesce to replace the null value
set @log = @Log + ' ,Date: ' + coalesce(@Date, 'NULL')
October 16, 2019 at 6:03 pm
I think you want to convert the date to varchar, and if the results is NULL, use the string NULL
ISNULL(convert(varchar(20),@Date,GETDATE()),110),'NULL')
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy