May 2, 2008 at 12:17 pm
Can somebody show me the basic syntax for an update select statement when I need multiple fields in the select? Do I need to do a subquery for each field? Thanks for the help.
May 2, 2008 at 1:31 pm
There are good examples in Books Online:
UPDATE dbo.Table2
SET dbo.Table2.ColB = dbo.Table2.ColB + dbo.Table1.ColB
,dbo.Table2.ColC = dbo.Table1.ColQ
FROM dbo.Table2
INNER JOIN dbo.Table1
ON (dbo.Table2.ColA = dbo.Table1.ColA);
No, you only need a single select statement, with joins, CTE's of whatever, that accurately defines the columns you wish to use in the update statements.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
May 2, 2008 at 2:00 pm
Thank you
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply