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 799277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:06:03+00:00 2026-05-14T23:06:03+00:00

Basically I have a User-Defined Table Type (for use as a table-valued variable) which

  • 0

Basically I have a User-Defined Table Type (for use as a table-valued variable) which I’m referencing in a stored procedure that effectively just calls two other stored procedures, then inserts those values into the table type.

Id est

INSERT INTO @tableValuedVariable (var1, var2, var3, var4, var5)
         EXEC [dbo].StoredProcedure1;

INSERT INTO @tableValuedVariable (var1, var2, var5)
         EXEC [dbo].StoredProcedure2;

You can probably already tell what I’m going to ask. Basically StoredProcedure2 only returns a few of the values the table is set to hold, and I’d like those other variables to just be null (as defined as default). Only SQL is complaining that I’m not specifying all the variables available to that table.

The return datasets can be quite sizable so I’d like to avoid loops and such for obvious reasons.

Thanks for any help.

  • 1 1 Answer
  • 3 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-14T23:06:03+00:00Added an answer on May 14, 2026 at 11:06 pm

    You have list all columns in the INSERT clause to match all columns from the stored proc.

    Now, if the stored proc returns var1, var2, var5 then there should be no need to specify var3, var4 in the INSERT clause if they are NULLable. (Edit: of course, as Mike Burton pointed out, it will fail if the columns are NOT NULL)

    If the stored proc returns var1, var2, var3, var4, var5 then you need all 5 in the INSERT clause: you can’t ignore columns from the stored proc and allow them to default.

    You could change the stored proc to a udf and SELECT var1, var2, var5 FROM mynewUDF()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this user-defined table type parameter, which is used in my scalar
I have a complex data structure (user-defined type) on which a large number of
Basically I have a single page site that scrolls when the user clicks on
I have a page which basically allows an admin user to create manager user
So basically, I have a bunch of TextBoxes that the user gets to fill
I have a boolean setting in my Properties/Settings.settings file, which basically stores per user
The Situation I have a table in a DB that contains job types, basically
Here's my user-defined table type... CREATE TYPE [dbo].[FooType] AS TABLE( [Bar] [INT], ) This
Basically I have a tabbed Panel I'm creating. When the user click on a
I have a view where the user can change some settings, its basically a

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.