Counter of Festivals

Ashok Blog for SQL Learners and Beginners and Experts

Wednesday, 13 March 2013

Set Default value in Stored Procedure




 Set Default value in Stored Procedure:

Create PROCEDURE dbo.my_proc
    @first int = NULL,  -- NULL default value
    @second int = 2,    -- Default value of 2
    @third int      -- Default value of 3
AS
    SET NOCOUNT ON;
    SELECT @first[1], @second[2], @third[3];



EXECUTE dbo.my_proc @third=5 -- only Third parameters supplied

EXECUTE dbo.my_proc 10, 20, 30;-- All new parameters supplied


EXECUTE dbo.my_proc 10, @third=25;-- first,third parameters supplied