SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Optional Parameter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shapper
Constraint Violating Yak Guru

446 Posts

Posted - 02/06/2007 :  11:22:12  Show Profile  Reply with Quote
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

United Kingdom
22403 Posts

Posted - 02/06/2007 :  11:24:03  Show Profile  Reply with Quote
"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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000