I'm trying to convert the query below to use table variables, but it isn't giving the same results:
UPDATE #TEMP1
SET #TEMP1.ExternalTradeID =
(
Select #TEMP2.ExternalTradeID From #TEMP2 WHERE #TEMP2.TOLNK = #TEMP1.TOLNK
)
WHERE #TEMP1.TOLNK <> ''
AND #TEMP1.ExternalTradeID = ''
Conversion query:
UPDATE @FIST_Transactions
SET ExternalTradeID = ET.ExternalTradeID
FROM @FIST_Transactions FT
INNER JOIN (
SELECT ETID.ExternalTradeID
,ETID.TOLNK
FROM @FIST_Transactions FT
INNER JOIN @ExternalTradeID ETID
ON FT.TOLNK = ETID.TOLNK) ET
ON FT.TOLNK = ET.TOLNK
WHERE FT.TOLNK <> ''
AND FT.ExternalTradeID = ''
What am I doing wrong?
UPDATE #TEMP1
SET #TEMP1.ExternalTradeID =
(
Select #TEMP2.ExternalTradeID From #TEMP2 WHERE #TEMP2.TOLNK = #TEMP1.TOLNK
)
WHERE #TEMP1.TOLNK <> ''
AND #TEMP1.ExternalTradeID = ''
Conversion query:
UPDATE @FIST_Transactions
SET ExternalTradeID = ET.ExternalTradeID
FROM @FIST_Transactions FT
INNER JOIN (
SELECT ETID.ExternalTradeID
,ETID.TOLNK
FROM @FIST_Transactions FT
INNER JOIN @ExternalTradeID ETID
ON FT.TOLNK = ETID.TOLNK) ET
ON FT.TOLNK = ET.TOLNK
WHERE FT.TOLNK <> ''
AND FT.ExternalTradeID = ''
What am I doing wrong?