Click here to Skip to main content
14,326,421 members
Rate this:
Please Sign up or sign in to vote.
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 4 days ago
Comments
Richard MacCutchan 4 days ago
   
Why not just reload from your backup? Oh, and also sack the person who corrupted the master.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

A proper statement is:
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[^]
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100