1

Here is my scenario:

I have 2 current tables (We'll call them DimA and DimB):

DimA has 2 columns (Key, ZipCode)
DimB has 5 columns (FirstName, LastName, Address, ZipCode, Key)

I need to:

 INSERT INTO DimB(Key) VALUES
     (SELECT Column(Key) FROM DimA WHERE dimA.ZipCode = dimB.ZipCode)

What is the absolute best way to go about making this work?

4

1 回答 1

2

听起来你想要UPDATE而不是INSERT. 否则,dimA.ZipCode = dimB.ZipCode表达式永远不会为真。

UPDATE b
SET b.Key = a.Key
FROM DimA a
INNER JOIN DimB b on b.ZipCode = a.ZipCode
于 2013-09-17T18:57:26.837 回答