sqlsql-serverdatabaset-sql

Pass explicit NULL value to stored procedure from T-SQL not from application


How do I pass a null value to my stored procedure within SSMS? I have set two of my parameters to optional e.g.,

 --This is inside my storedproc
 @name varchar(50)
 @surname varchar(50) = null,
 @text varchar(255) = null,

Now to execute

 --Now execute without the 'text'
 EXEC sp_bla 'Noob Question Name', 'Noob Surname'

Solution

  • EXEC sp_bla NULL, 'Noob Question Name', 'Noob Surname'
    

    Basically, just pass NULL as parameter value in the required position