A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi @Sudip Bhatt ,
As mentioned by other experts, we must add an ALIAS on the subquery.
The alias after the subquery (or derived table, if you prefer) is required by SQL Server. It is not only a requirement but a really good idea. In general, column references should be qualified, meaning that they include a table alias. Without an alias, references to columns in the subquery could not be qualified. I think that's a bad thing.
So please refer below query:
SELECT * INTO #XmlData FROM
(
SELECT d.v.value('(LineItem/text())[1]','VARCHAR(MAX)') AS LineItem,
d.v.value('(XFundCode/text())[1]','VARCHAR(MAX)') AS XFundCode
FROM @XmlData.nodes('/Root/TickerTemplate') AS d(v)
) t
UPDATE lt
SET lt.XFundCode = a.XFundCode
From TblLineItemTemplate lt INNER JOIN #XmlData a ON lt.LineItem=a.LineItem
WHERE lt.TickerID=@TickerID
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.