更新多列的CTE

时间:2014-02-11 05:14:03

标签: sql-server-2005

我使用来自2个表的数据导出CTE,并且我需要在此CTE中更新2列。我可以使用UPADTE CTE然后使用case语句来更新一列,但第二列。

例如

update cte  
set col1 = case when thisrecord = thatrecord then 1 else 0 end 
    col2 = case max(thisrecord) = max(thatrecord) then 1 else 0 end

它给了我错误。

如果我使用

update cte 
set col1, set col2 
from cte 
where this = that

然后它说cte不可更新,因为它有多个基表。

如何解决这个难题,是否有人有类似的情况或可能的工作?

0 个答案:

没有答案
相关问题