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 |
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2010-04-14 : 09:25:44
|
| hi i need to update with single query like below UPDATE ASET CODE = C.CodeFROM [dbo].[TESTA] A INNER JOIN [dbo].[TESTB] B ON A.ID = B.ID INNER JOIN [dbo].[TESTC] AS C ON B.KEYNM = C.KEYNM WHERE A.NAME = 'R'GROUP BY C.KEYNMHAVING C.KEYNM In (60,70)but getting errorMsg 156, Level 15, State 1, Line 9Incorrect syntax near the keyword 'GROUP'.T.I.Aneed help |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-14 : 09:31:38
|
Why are you using GROUP BY and HAVING? Does this not do what you want? UPDATE ASET CODE = C.CodeFROM [dbo].[TESTA] AINNER JOIN [dbo].[TESTB] BON A.ID = B.IDINNER JOIN [dbo].[TESTC] AS CON B.KEYNM = C.KEYNMWHERE A.NAME = 'R'AND C.KEYNM In (60,70) ------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2010-04-14 : 09:44:03
|
| thanks for ur replybut actually i need that group by clause as in that table most of values are duplicate having different values in other columns..T.I.ADo needful |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2010-04-14 : 09:55:22
|
| how about the following type of structure?update a set a.col1 = d.cdfrom (select b.col1 as ab, sum(c.x) as cd from b inner join c on b.col2 = c.col2 where b.y = "z" group by b.col1) d |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-14 : 09:59:56
|
| Perhaps you could explain in detail exactly what it is you're trying to achieve.------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
|
|
|