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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:56:37+00:00 2026-06-17T18:56:37+00:00

A table is populated by the following stored procedure: exec(‘ insert into tblSegments (SegmentName,

  • 0

A table is populated by the following stored procedure:

exec('
insert into tblSegments
    (SegmentName, CarTypeID, EngineTypeID, AxleTypeID)
select distinct
    ''' + @SegmentName + '''
    , CT.CarTypeID
    , ET.EngineTypeID
    , AT.AxleTypeID
from
    tblCarTypes CT
        cross join tblEngineTypes ET
        cross join tblAxleTypes AT
where
    CT.CarTypeName in (' + @CarTypes + ')
    and ET.EngineTypeName in (' + @EngineTypes + ')
    and AT.AxleTypeName in (' + @AxleTypes + ')
')

parameters, with the exception of @SegmentName, are strings such as (for @CarTypes) 'hatchback','suv','sedan'.

Can the data in the table be used to create a list, for a single SegmentName, of the previous entries to the stored procedure akin to

Run1: @CarTypes, @EngineTypes, @AxleTypes
Run2: @CarTypes, @EngineTypes, @AxleTypes
Run3: @CarTypes, @EngineTypes, @AxleTypes

…?

Runs don’t need to be in sequential order. The process can involve a combination of T-SQL and C#. I’m pretty sure this is impossible; perhaps someone can prove me wrong.

  • 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-06-17T18:56:38+00:00Added an answer on June 17, 2026 at 6:56 pm

    No, it’s not possible because you’re taking in a potentially comma-delimited string of values which will create separate rows in your result table. You can easily get a single value each for the CarTypes, EngineTypes and AxleTypes variables, but to group them separately by each execution of your dynamic SQL you would need some kind of executionID column or something to group the rows on per execution.

    So you’re correct in that what you want to do is completely possible, but not with the schema design you’ve provided. I would just create another table and populate it at runtime if this is information you want to keep. You could put an identify column on the table that houses the input variables and use the @@IDENTITY for the insert into that table to populate an executionID column in your main table so you can easily associate the variable summary table with the cross joined result table.

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

Sidebar

Related Questions

Lets say we have a table here, populated with the following data: acc_id1 acc_id2
I created the following code to populate a table with data stored in database.
I am currently trying to re-write a stored procedure to take into account the
I have a table populated with time stamped rows inserted at (essentially) random point
Using a populated Table Type as the source for a TSQL-Merge. I want to
I need to add a NOT NULL column to an existing (populated) table that
I have a large table that get populated from a view. This is done
I have two columns in a table that are populated with integer values. For
How do I differentiate between elements inside a table that is populated using a
I have a table (in a form) populated with radio buttons (with a button

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.