MyITBlog.com - IT Professionals Online Journal
 
  Home  |   Site News  |   About Us  |   Privacy  |   FAQ  |   Contact   Add Blog Entry  |  Login  |  Register   
   HOME  >  Programming  >  Database

Passing Optional Parameters to a Stored Procedure
by Thivya on 06 Mar 2006, 09:30
Total Hits: 2320    Comments: 0   Votes: 0
Category: Database     

To pass a optional parameters to a stored procedure in SQL Server, declare the parameter with the default value.

Create Procedure proc_Test

@a int,

@b int =5 -- Provided with the default value.

as

begin

       Select @a, @b

end

Note:

When using optional parameters at first, specify it with the parameter name during execution

For example, if @a is an optional parameter, to execute this stored proecedure, specify it as follows 

EXEC proc_Test @b=3