Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How can i make SP have optional Parameter ?

Author  Topic 

ya3mro
Starting Member

37 Posts

Posted - 2006-06-21 : 08:24:48
i want to know if i can make stored procedure have optional parameter ??

i mean that SP have a parameter that can be passed or not ??

can that br done ?

How I Came To Islam?
http://english.islamway.com

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-06-21 : 08:34:27
Give it a default value. I.e.:
CREATE PROC #myproc (@param INT = NULL)
AS
SELECT @param

-- Return NULL value
EXEC #myproc

-- Return 10
EXEC #myproc 10


Mark
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-21 : 09:11:01
Also note that optional parameters should be declared last in the parameter lists

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ya3mro
Starting Member

37 Posts

Posted - 2006-06-21 : 13:52:59
thanx to All

How I Came To Islam?
http://english.islamway.com
Go to Top of Page
   

- Advertisement -