December 7, 2011 at 8:16 am
Hi, I have two table variables with two fields each. The definitions are as below:-
declare @DocData table (fileId uniqueidentifier, PDFExists bit)
declare @PDFData table (fileId uniqueidentifier, OriginalFileId uniqueidentifier)
Now, I want to update the column PDFExists =1 where @DocData.fileId=@PDFData.OriginalFileId. I tried
update @DocData set PDFExists=1 where @DocData.fileId=@PDFData.OriginalFileId
But I get error saying @DocData is not declared.
What is wrong in the update query?
December 7, 2011 at 8:26 am
update dd set PDFExists=1
FROM @DocData dd INNER JOIN @PDFData pdf ON dd.fileId=pdf.OriginalFileId
Other than the missing join, the table variables either need to be aliased or enclosed in []
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 9, 2011 at 8:32 am
Thanks for the quick reply..... It worked with that
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy