更新涉及两个不同目录的语句

时间:2010-09-22 18:23:06

标签: sql sql-server tsql sql-update

尝试执行当前db想要从昨晚的备份中提取值的单个字段的更新。应该接近:

update myTable 
   set status = (select status 
                   from .lastBackup.dbo.myTable as t 
                  where t.idField = idField)

帮助?

1 个答案:

答案 0 :(得分:5)

试试这个:

update t
    set status = b.status
    from myTable t
        inner join lastBackup.dbo.myTable b
            on t.idField = b.idField