As I do the following copy a column from one table to another table

I explain in database as I do if in database users.bod.Users_Master I have 18.000 accounts or more and I made the mistake of adding 2.000.000 points in the points column but before I had a backup which shows that the maximum of some user was 63.000 points now I need to make a rollback of the column specifies points if I do Restore I will put that the backup backup will be like this : backup.bod.Users_Master

I imagine it will be a UPDATE using a select so that only this column is passed try with this one but it doesn't work. I repeat I do not want to add or subtract I just want to copy by an UPDATE the selected column crei was like this:

UPDATE b
SET b.point = o.point
FROM Usuarios.dbo.Users_Master  
INNER JOIN Respaldo.dbo.Users_Master 

But what I want to do is if user No. 1 in backup.bod.Users_Master has 2 points this update the users.bod.Users_Master the # 1 user who has 20,000 asi points on all records the database has with a single script I had to do this step by step to update all user columns

SELECT Point, Usuario FROM Respaldo.dbo.Users_Master WHERE Point > 10000

Copy the result column by column with MauseRecorder to make it automatic Calro no human could with so much record

Then release this update

UPDATE Usuarios.dbo.Users_Master SET Point = 'PEGUE uno x uno los resutados del Setect respaldo' WHERE Usuario = 'Pegue 1x1 cada Usuario Corespondiente a su puntos de respaldo'

There has to be some shorter way to do this without copying or pasting 1 x one

The friend who gave me this Script I don't work

UPDATE PS_GameData.dbo.Chars
    SET Family = PS_Restore.dbo.Chars.Family
    FROM PS_GameData.dbo.Chars
INNER JOIN PS_Restore.dbo.Chars
    ON PS_Restore.dbo.Chars.UserUID=PS_GameData.dbo.Chars.UserUID;

Gives me this error which does not I understand

Msg 1013, Level 16, State 1, Line 1
The objects "PS_Restore.dbo.Chars" and "PS_GameData.dbo.Chars" in the FROM clause have the same exposed names. Use correlation names to distinguish them.

Try with this other but it gives me error as I want to copy the whole record

UPDATE PS_GameData.dbo.Chars
    SET Family = (SELECT Family FROM PS_Restore.dbo.Chars),
        Job = (SELECT Job FROM PS_Restore.dbo.Chars)

The error it gives me is:

Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

Success I found this Script works Me Perfect Now I would like to know why the Iner Join I never work

UPDATE PS_GameData.dbo.Chars
    SET Family = b.Family,
        Job = b.Job
    FROM    PS_Restore.dbo.Chars b
WHERE PS_GameData.dbo.Chars.CharID = b.CharID;  
 0

2 answers

The JOIN did not work for you because the database handler does not know if the column Family is from the database PS_Restore.dbo.Chars or from the PS_GameData.dbo.Chars

To fix this and make the statement of UPDATE work together with the INNER JOIN you have to put an alias to each table:

UPDATE PS_GameData.dbo.Chars
    SET PS_GameData.dbo.Chars.Family = B.Family
FROM PS_GameData.dbo.Chars A
    INNER JOIN PS_Restore.dbo.Chars B
        ON B.UserUID = A.Chars.UserUID;
 0
Author: Phi, 2016-12-12 05:38:50

In the JOIN you lack the relationship condition between tables:

UPDATE Usuarios.dbo.Users_Master
    SET Point = Respaldo.dbo.Users_Master.Point
    FROM Usuarios.dbo.Users_Master
INNER JOIN Respaldo.dbo.Users_Master
    ON Respaldo.dbo.Users_Master.Usuario=Usuarios.dbo.Users_Master.Usuario;
 0
Author: Asier Villanueva, 2016-08-16 14:21:48