I want to create a stored procedure. One of the parameters ....
@ID int not null,
is giving me an error:
NOT NULL parameters are only supported with natively compiled modules, except for inline table-valued functions.
how can I fix this?
I want to create a stored procedure. One of the parameters ....
@ID int not null,
is giving me an error:
NOT NULL parameters are only supported with natively compiled modules, except for inline table-valued functions.
how can I fix this?
if you want to have required
parameter for a stored procedure then just declare the parameter like below, then check whether param is null or not
Create procedure MyProc
@ID int
as
if @ID is null
begin
-- handle the null case here
end
-- rest of your query
If the parameter is optional then assign null
to the parameter, which acts as a default value if no input is provided in procedure call
Create procedure MyProc
@ID int = null
as
-- your query
You can throw an error if the parameter is null in the beginning of your SP
IF @ID IS NULL
BEGIN
RAISERROR (15600,-1,-1,'myProcedure');
END