Reputation: 1928
I'm trying to update my tables and move the data from table "User" with a "Pass" column to table "Partners" to a column with the same name "Pass". i tryed a lot fo things and i give up now. i need your help! the code i am using is this one:
UPDATE [databasename].[dbo].[Partners]
SET [Pass] = [User].[Pass]
WHERE [Code] = [User].[Code]
UPDATE [databasename].[dbo].[User]
SET [Pass] = [Partners].[Pass]
WHERE [Pass] = [Partners].[Pass]
but im getting this error:
Msg 170, Level 15, State 1, Line 3 Line 3: Incorrect syntax near 'Pass'.
Upvotes: 0
Views: 39
Reputation: 18411
UPDATE P
SET [Pass] = U.[Pass]
FROM [databasename].[dbo].[Partners] P
JOIN [databasename].[dbo].[User] U
ON U.[Code] = P.[Code]
Upvotes: 3
Reputation: 93141
You need to learn some basic SQL Server syntax:
UPDATE P
SET P.Pass = U.Pass
FROM [nima08].[dbo].[Partners] P
INNER JOIN [nima08].[dbo].[User] U ON P.Code = U.Code
UPDATE U
SET U.Pass = P.Pass
FROM [nima08].[dbo].[User] U
INNER JOIN [nima08].[dbo].[Partners] P ON U.Pass = P.Pass
Upvotes: 1