Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
paull
Yak Posting Veteran
50 Posts |
Posted - 2009-06-30 : 07:53:22
|
| Hi allI have a very quick (and I thought easy!) update to do on a table (V).The table basically looks like..ID Col1 Col2 Col3 NewCol1 Newcol2123 aaa bbb cccI also have another table (F) which I need to get the conditionID Q1 Q2 Q3 123 1 0 2All I want to do is update NewCol1 with Col1 Where F.Q1=1. I thought this would be easy but I got stuck doing case whens and then trying to insert into a new table and ended up thoroughly confused!!!I hoped for ...UPDATE TableV vJoin TableF f SET v.[NewCol1] = Case when f.Q1 = 1 then v.[Col1] endAny help would be greatly appreciated!ThanksP |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2009-06-30 : 08:45:21
|
| moved from script library forum.___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.5 out! |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-06-30 : 09:20:34
|
| update Vset V.newcol1 = V.col1from TableV V inner join TableF F on V.ID = F.IDwhere F.Q1 = 1 |
 |
|
|
|
|
|