Click here to Skip to main content
15,868,102 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We have a challenge some one run sql script to update username on the database against master db now all the username on the master db have one common username.
Can someone please Help us we want to Update username column in the master database by selecting username from another database in XAUser table below is script that I tried but am struggling with update part to the master db.

What I have tried:

User master


select X.UserID,X.UserInit

from DBLive.[dbo].XaUser X

update master
set UserInit = UserInit
where UserID = X.UserID
Posted
Updated 9-Oct-19 23:41pm
Comments
Richard MacCutchan 10-Oct-19 5:04am    
Why not just reload from your backup? Oh, and also sack the person who corrupted the master.

1 solution

A proper statement is:
SQL
UPDATE
    Table_A
SET
    Table_A.col1 = Table_B.col1,
    Table_A.col2 = Table_B.col2
FROM
    Some_Table AS Table_A
    INNER JOIN Other_Table AS Table_B
        ON Table_A.id = Table_B.id
WHERE
    Table_A.col3 = 'cool'


For further details, please see: How do I UPDATE from a SELECT in SQL Server? - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900