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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:54:48+00:00 2026-05-21T20:54:48+00:00

I need to update select occurrences in different tables of the [ISD_ID] attribute, how

  • 0

I need to update select occurrences in different tables of the [ISD_ID] attribute, how might I accomplish this?

I can grab the set of tables that possess the records I’m looking for with this statement:

SELECT c1.TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS c1
INNER JOIN information_schema.COLUMNS c2
ON c1.TABLE_NAME = c2.TABLE_NAME
 WHERE c1.COLUMN_NAME LIKE '%isd%id%' and c2.column_name LIKE '%schooldistrict%id%'

So now I have a set of table names that I’d like to iterate through, updating records as necessary.

Per a suggestion in another post, I’ve read up on Dynamic SQL. So I could do something like EXECUTE IMMEDIATE: ('update' + @tablename + ' set ISD_ID=37 where SchoolDistrictID=46') .

My question, then, is: how can I iterate through my table names and substitute them into the above statement as the @tablename variable, so that I can update the values in each table?

I also have the ability to use .NET and SSIS if need be.

Thanks in advance; I’m not so proficient with SQL and appreciate the opportunity to learn.

  • 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-21T20:54:49+00:00Added an answer on May 21, 2026 at 8:54 pm
    • A weird way
      You can use an undocumented stored procedure (please don’t tell Remus Rusanu I said that), to do something like this. You’d use the @where condition to specify that the table has to contain a given column.

    • A more conventional way would be to

      1. select the results of the query into a temp table or a table variable
      2. iterate over the temp table/table variable, using a while loop, grabbing the name of the table and substituting into the @tablename variable
      3. Execute your query above. Warning, you’d probably want to create variable called something like @myDynamicSQL, set the statement text to it, and then call EXEC IMMEDIATE on it.

    Honestly, by the time you are done with “weird way”, you’d be better off doing it the conventional way, but I’m just trying to be thorough.

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

Sidebar

Related Questions

I need write an update statement that used multiple tables to determine which rows
I need to update some rows of the tables and then display these rows.
Suppose I need to update myTab from luTab as follows update myTab set LookupVale
I need to update a row of alarms with Linq to SQL, which can
I need to update an application so that when a user clicks on a
This is along the lines of what I want to do: UPDATE [table1] SET
i need update fields 'ErrCode' from select between 2 table. i try query it's
I need to update a row in an Oracle database in a way that
Here is the Select I need to convert to an Update: SELECT DISTINCT f.SectionID,
I need this update query to run on both SQL Server and Oracle. Our

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.