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 2005 Forums
 Transact-SQL (2005)
 Optional Parameter

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-02-06 : 11:22:12
Hello,

Is it possible for a procedure to have an optional parameter so that the procedure runs different code either the parameter is defined or not.

Thanks,
Miguel

Kristen
Test

22859 Posts

Posted - 2007-02-06 : 11:24:03
"Is it possible for a procedure to have an optional parameter"

Yes

"so that the procedure runs different code either the parameter is defined or not"

Bit more difficult. You can set an optional parameter to a given (i.e. default) value if it is not provided. If you set the default value to be something that your application will NEVER pass then you can detect that, programmatically, in the logic of your Procedure and run the appropriate conditional code.

Kristen
Go to Top of Page
   

- Advertisement -