2013-05-31 134 views

回答

1

這應該工作。我不確定你有什麼樣的數據,但沒有辦法鏈接Table2和Table1,但是:

WITH T1 AS 
(
    SELECT 
     RN = ROW_NUMBER() OVER (ORDER BY NULL) 
     ,Col1 
    FROM 
     Tbl1 

) 
,T2 AS 
(
    SELECT 
     RN = ROW_NUMBER() OVER (ORDER BY NULL) 
     ,Col1 
    FROM 
     Tbl2 

) 

UPDATE 
    T1 
SET 
    Col1 = T2.col1 
FROM 
    T1 
INNER JOIN 
    T2 
     ON T1.RN = T2.RN 
+0

但是我需要用tbl2.col1更新tbl1.col1。 – GLP

+0

@GLP更新,以滿足實際要求:) – JNK

+0

謝謝。這樣可行! – GLP

相關問題