I have 3 Databases. One of them contains wrong data.
The structure is like:
DB_1:
Tbl:
ID - otherID - Guid
DB_2:
Tbl:
ID - otherID - Guid
DB_3:
Tbl:
ID - otherID
DB_1 Containes the "otherID" that should stored in DB_3.
The "Guid" of DB_1 and BD_2
and the "otherID" of DB_2 and DB_3 match
How to update the DB_3 "oderID" with DB_1 "otherID"?
My first try was:
SELECT A.otherID
FROM [DB_1].dbo.tbl A, [DB_2].dbo.tbl B
WHERE A.Guid = B.Guid;
But then I had some trouble to use it for the update statement.
so the result was like:
UPDATE [BD_3].dbo.Tbl
SET [BD_3].dbo.Tbl.otherID =
(
SELECT A.otherID
FROM [DB_1].dbo.tbl A,
[DB_2].dbo.tbl B,
[DB_3].dbo.tbl C
WHERE C.otherID = B.oterID
AND A.guid = B.guid
);
I found something, but that has not really helped me, because I don`t know how to use it for this case.
the line RAISERROR 44447 'Some Message.' contains the error. the number is underlined – Wr4thon Aug 21 '13 at 12:52