简体   繁体   English

SQL Server 2005:将数据从一个表转移到另一个表

[英]SQL Server 2005: Transfer data from one table to other

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'. 消息170,级别15,状态1,第3行第3行:“传递”附近的语法错误。

UPDATE P
SET    [Pass] = U.[Pass]
FROM   [databasename].[dbo].[Partners] P
       JOIN [databasename].[dbo].[User] U
           ON U.[Code] = P.[Code]

You need to learn some basic SQL Server syntax: 您需要学习一些基本的SQL Server语法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM