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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:09:57+00:00 2026-05-15T03:09:57+00:00

A simple question about Stored Procedures. I have one stored procedure collecting a whole

  • 0

A simple question about Stored Procedures.

I have one stored procedure collecting a whole bunch of data in a table. I then call this procedure from within another stored procedure. I can copy the data into a new table created in the calling procedure but as far as I can see the tables have to be identical.

Is this right? Or is there a way to insert only the data I want?

For example….

I have one procedure which returns this:

SELECT
@batch as Batch,
@Count as Qty,
pd.Location,
cast(pd.GL as decimal(10,3)) as [Length],
cast(pd.GW as decimal(10,3)) as Width,
cast(pd.GT as decimal(10,3)) as Thickness
FROM propertydata pd
GROUP BY
pd.Location,
pd.GL,
pd.GW,
pd.GT

I then call this procedure but only want the following data:

DECLARE @BatchTable TABLE (
Batch varchar(50),
[Length] decimal(10,3),
Width decimal(10,3),
Thickness decimal(10,3),
)

INSERT @BatchTable (Batch, [Length], Width, Thickness)
EXEC dbo.batch_drawings_NEW @batch

So in the second command I don’t want the Qty and Location values.

However the code above keeps returning the error:

“Insert Error: Column name or number of supplied values does not match table”

  • 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-15T03:09:58+00:00Added an answer on May 15, 2026 at 3:09 am

    The tables don’t have to be identical, the results of the query from the first stored proc need to match the columns defined in the second, and they don’t.

    You need to change the first stored procedure to not return Qty and Location.

    Select Batch, [Length], Width, Thickness FROM (
    SELECT @batch as Batch, @Count as Qty, pd.Location, cast(pd.GL as decimal(10,3)) as [Length], cast(pd.GW as decimal(10,3)) as Width, cast(pd.GT as decimal(10,3)) as Thickness 
    FROM propertydata pd GROUP BY pd.Location, pd.GL, pd.GW, pd.GT) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get started with subsonic but have a simple question about stored procedures
I have a simple question about the barplot function. I have a TRUE/FALSE table
I have a small question about stored procedures and the DateTime2 datatype in SQL
I have a simple question about Java's XML API and I hope there's a
I have a fairly simple question about these 2 templating engines. I'm trying to
I have what I hope is a fairly simple question about using the value
One more question about most elegant and simple implementation of element combinations in F#.
I have read these very good questions on SO about SQL stored procedures: When
I am learning C programming and I have a simple question about pointers... I
I have a relatively simple case. I basically want to store data about links

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.