Avoid giving users a null value for a stored procedure in SQL Server

I am curious as to why this won't work:

create procedure test
     @id int not null,
    @feature bit not null

      

Shows 'Invalid syntax to be null' for the first line.

[I do not want my users to provide null for SP and hence try to explicitly avoid the same.]

+3


source to share


1 answer


This feature was introduced in SQL Server 2014 using built-in stored procedures. If you are not already using 2014, you will have to resort to other prevention methods:

  • Stop it even from accessing the database in your application code / logic (often we don't have access to this though)
  • Make the first part of you SP a null check and break out or throw an error if it is null
  • Too many options to go on ...


Link: https://msdn.microsoft.com/en-us/library/dn452286(v=sql.120).aspx

+1


source







All Articles