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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:13:00+00:00 2026-05-27T11:13:00+00:00

Is there a way to do foreach value do something in sql server 2008.

  • 0

Is there a way to do foreach value do something in sql server 2008.

I have a table variable that holds some IDs and i have to some more tasks based on the values.

The table vairable is as follows:

declare @InspectionIDTable table(InspectionID uniqueidentifier not null)

based on the values in this table i need to loop and run some select statements. based on the result i have to populate other table variables and do some more processing.

basically, i required foreach in sql server that can have nested foreach. Is there a clean apporach to do this.

Also, i would like to know whether it is a good approach to do this in Stored Procedure from programming point of view.

  • 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-27T11:13:01+00:00Added an answer on May 27, 2026 at 11:13 am

    You could write a stored procedure and open a cursor on your “resultset”

    http://sqlserverplanet.com/tsql/sql-server-for-each-row-next/

    Anyway you should avoid to use cursors because their bad performance

    There is a way to do row-by-row operations without cursors

    Have a look at the below:

    http://www.sql-server-performance.com/2004/operations-no-cursors/

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

Sidebar

Related Questions

In SQL Server, I have a table where a column A stores some data.
Within a Foreach loop in SSIS is there a way that if a task
Is there any way to do some kind of while() for each post variable
I have a table of users in SQL Server with all the contact details,
I have a table with something like a dozen different columns. Is there a
I have a perl variable $results that gets returned from a service. The value
I have some data in SQL Server as: att1 att2 att3 att4 att5 ...
Is there a way to do foreach style iteration over lined up enumerables in
Is there a way to iterate (through foreach preferably) over a collection using reflection?
Is there a way to use a foreach loop to iterate through a collection

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.