Check if a parameter is null or empty in a stored procedure

I sometimes use NULLIF like so...

IF NULLIF(@PreviousStartDate, '') IS NULL

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 :-)


Here is the general pattern:

IF(@PreviousStartDate IS NULL OR @PreviousStartDate = '')

'' is an empty string in SQL Server.


I use coalesce:

IF ( COALESCE( @PreviousStartDate, '' ) = '' ) ...

you can use:

IF(@PreviousStartDate IS NULL OR @PreviousStartDate = '')