SQL Server Programming Part 4 - Output Parameters & Return Values

I'm writing some stored procs in SQL Serverand wondered if the concept of optional input parameters is possible here? I suppose I could always pass in NULL for parameters I don't want to use, check the value in the stored proc, then take things from there, but I was interested if the concept is available here.

Now you don't even have to pass the parameter in. It will default to NULL or whatever you choose to default to.

sql - Stored Procedure parameter default value - is this a constant or a variable - Stack Overflow

By posting your answer, you agree to the privacy policy and terms of service. Stack Overflow Questions Developer Jobs Documentation beta Tags Users. Sign up or log in to customize your list. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.

Log In Sign Up. Join the Stack Overflow Community.

Stack Overflow is a community of 7. Join them; it only learn to trade stocks with russ whitney a minute: FMFF mssql stored procedure default parameter value 19 Thanks for both of your answers!

Answering RKSharma for anyone who's wondering too - it works just the same with uniqueidentifiers.

Default parameter values in SQL Server stored procedure - Stack Overflow

Declare parameter as mssql stored procedure default parameter value Mike Cole 6, 19 86 Are you sure you don't need it? You can pass it in as NULL, but then you just shift that logic to the application s that use the procedure.

Adding to Aaron's point. The reason is, you may not be aware of ALL the code that calls this proc.

Using default values for stored procedure parameters

Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password.

Post as a guest Name. Stack Overflow works best with JavaScript enabled. Take a long read at Erland's site, he has some great info on dynamic search conditions: MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Rating 4,7 stars - 587 reviews
inserted by FC2 system