Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 933755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:53:11+00:00 2026-05-15T20:53:11+00:00

I have a stored procedure that has a bunch of input and output parameters

  • 0

I have a stored procedure that has a bunch of input and output parameters because it is Inserting values to multiple tables. In some cases the stored proc only inserts to a single table (depending on the input parameters). Here is a mocked up scenario to illustrate.

Tables / Data Objects:

Person

Id
Name
Address

Name

Id
FirstName
LastName

Address

Id
Country
City

Say I have a stored procedure that inserts a person. If the address doesn’t exist I won’t add it to the Address table in the database.

Thus when I generate the code to call the stored procedure I don’t want to bother adding the Address parameter. For INPUT parameters this is ok because SQL Server allows me to supply default values. But for the OUTPUT parameter what do I do in the stored procedure to make it optional so I do not receive an error…

Procedure or function ‘Person_InsertPerson’ expects parameter
‘@AddressId’, which was not supplied.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:53:11+00:00Added an answer on May 15, 2026 at 8:53 pm

    Both input and output parameters can be assigned defaults. In this example:

    CREATE PROCEDURE MyTest
      @Data1 int
     ,@Data2 int = 0
     ,@Data3 int = null output
    
    AS
    
    PRINT @Data1
    PRINT @Data2
    PRINT isnull(@Data3, -1)
    
    SET @Data3 = @Data3 + 1
    
    RETURN 0
    

    the first paramter is required, and the second and third are optional–if not set by the calling routine, they will be assigned the default values. Try messing around with it and the following test-call routine in SSMS using different values and settings to see how it all works together.

    DECLARE @Output int
    
    SET @Output = 3
    
    EXECUTE MyTest
      @Data1 = 1
     ,@Data2 = 2
     ,@Data3 = @Output output
    
    PRINT '---------'
    PRINT @Output
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a stored procedure that has to retrieve data from multiple tables something
I have a very large SELECT stored procedure that has multiple return columns and
I have a stored procedure for SQL 2000 that has an input parameter with
I have a stored procedure on my server that inserts some parameters and returns
I have SQL Server 2000 and I have a stored procedure that has @output
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to
I have a stored procedure that has this line: SET @SQL = 'SELECT path,title,tags
I have a stored procedure that has been working just fine, but I recently
I have a stored procedure that takes no parameters, and it returns two fields.
I have a stored procedure that has this select statement in it: select (select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.