I know how to check if a parameter is null but i am not sure how to check if its empty … I have these parameters and I want to check the previous parameters are empty or null and then set them like below
ALTER PROCEDURE [dbo].[GetSummary]
@PreviousStartDate NVARCHAR(50) ,
@PreviousEndDate NVARCHAR(50) ,
@CurrentStartDate NVARCHAR(50) ,
@CurrentEndDate NVARCHAR(50)
AS
BEGIN
IF(@PreviousStartDate IS NULL OR EMPTY)
SET @PreviousStartdate = '01/01/2010' for example..
I would appreciate the help.
I sometimes use NULLIF like so…
There’s probably no reason it’s better than the way suggested by @Oded and @bluefeet, just stylistic preference.
@danihp’s method is really cool but my tired old brain wouldn’t go to COALESCE when I’m thinking is null or empty 🙂