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 |
|
amsqlguy
Yak Posting Veteran
89 Posts |
Posted - 2009-06-26 : 12:59:34
|
| Guys, I have table which has a flag that indicates if the empid is populated mutliple times how do I update the flag in case of multiple employee ids. Any suggestions and inputs would helpEMPID MULTIPLEFLAG1 N2 N3 Y3 Y |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-26 : 13:02:33
|
Try this:update t1set MULTIPLEFLAG='Y'from table t1join(select EMPID from table group by EMPID having count(*) > 1)dton dt.EMPID = t1.EMPID No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-26 : 13:51:31
|
| [code]UPDATE tSET t.MULTIPLEFLAG='Y'FROM (SELECT COUNT(EMPID) OVER (PARTITION BY EMPID) AS Occur, MULTIPLEFLAG FROM YourTable)tWHERE t.Occur>1[/code] |
 |
|
|
|
|
|