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