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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:11:38+00:00 2026-06-15T12:11:38+00:00

UPDATE table2 SET table2.col1 = table1.col1, table2.col2 = table1.col2, table2.col3 = table2.col3, … FROM

  • 0
UPDATE table2 
SET table2.col1 = table1.col1, 
table2.col2 = table1.col2,
    table2.col3 = table2.col3,
...
FROM table1, table2 
WHERE table1.memberid = table2.memberid

Please help me to understand how to implement SET clause when there are 9-10 rows, and with common column name SCRIPT_ID so that script can be used again in the future to update the same table.

Here is a snippet from the table:

____     _____________   __________________  _____     _     _____
 999     EMS02075SVC     Host Controller     15099     3     60000 
1000     EMS02075SVC     DSM Controller      15099     1     60000 
1001     EMS02075WEB1    Application Server   4447     1     60000
  • 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-15T12:11:39+00:00Added an answer on June 15, 2026 at 12:11 pm

    This will work if your source and destination tables are identical and have the same memberids (which I assume are primary keys):

    UPDATE destination 
    
    SET destination.col1 = source.col1, 
    destination.col2 = source.col2,
    destination.col3 = source.col3,
    ...
    FROM table1 AS source
    JOIN table2 AS destination ON source.memberid = destination.memberid
    

    If your source and destination tables are identical, but your source has new rows (records) that the destination lacks, you’ll need an selective INSERT statement:

    INSERT INTO table2 (
        col1,
        col2,
        col3,
        ...
    ) SELECT col1, col2, col3, ... 
    FROM table1 
    WHERE NOT EXISTS (
        SELECT memberid 
        FROM table2 
        WHERE table2.memberid = table1.memberid)
    

    The above will only insert records that are not already in your destination table. Since you’re using SQL Server 2008, you might try playing with the MERGE statement which should handle both situations and whatever else you code into it in one set of code.

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

Sidebar

Related Questions

UPDATE TABLE1 set TABLE1.col1 = TABLE2.col1 FROM TABLE2 INNER JOIN TABLE3 ON COL2 =
I'm trying to do something like this in postgres: UPDATE table1 SET (col1, col2)
Update a table joining 1 more table. UPDATE t1 SET t1.col1 =1 FROM table1
UPDATE table1 SET col = 1 WHERE col2 = 'xyz' UPDATE a SET col
I have a simple sql call like :- select col1,col2 from table1 and sometimes
I have an update query like following: update table TABLE1 set COL1 = 'X'
I'm trying to make a query like so: UPDATE table1 SET col1 = 'foo',
Assume you have the following update: Update table set col1 = func(col2) where col1<>func(col2)
I have this SQL update query: UPDATE table1 SET table1.field1 = 1 WHERE table1.id
I have a stored procedure that says update table1 set value1 = 1 where

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.