Reputation: 79
DECLARE @sample varchar(1)
insert into tblSample (Column1) values(@sample)
then not passing any values to @sample.
I want to insert whenever I call the stored procedure even though the parameter is not supplied. Thanks
Upvotes: 0
Views: 71
Reputation: 1
Either use a null default in a stored proc parameter, then set a default before the insert.
Or, you can set a default constraint on the table for that column.
Upvotes: 0
Reputation: 5094
why you will want to insert even if no parameter is supplied ?
what is the exACT REQUIREMENT ?
Upvotes: 0
Reputation: 6543
You can simply add default value NULL for parameter of SP. But make sure that your table allow NULL value in that column. If you will not pass any value to parameter then it will take NULL as default like below :
CREATE PROCEDURE TestProc (@sample varchar(1) = NULL)
AS
BEGIN
insert into tblSample (Column1) values(@sample)
END
Upvotes: 2