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 |
|
MMMY
Starting Member
14 Posts |
Posted - 2012-04-25 : 09:09:37
|
Table Example:ID NAME FLAG1 Bill null 2 Bill null3 Bill null4 Bob null5 Henry null6 Henry null I want to keep the flag empty for one record and mark the rest as duplicates so the output would be:ID NAME FLAG1 Bill null 2 Bill D3 Bill D4 Bob null5 Henry null6 Henry D How can I go about doing this? Thank you very much! |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-04-25 : 09:13:50
|
update dtset FLAG = 'D'from(select row_number() over (partition by NAME order by ID) as rnum,* from YourTable)dtwhere rnum > 1 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
MMMY
Starting Member
14 Posts |
Posted - 2012-04-25 : 09:40:32
|
| Thank you very much! |
 |
|
|
Subarcticguy
Starting Member
2 Posts |
Posted - 2013-11-18 : 18:40:47
|
| I am trying to do something similar in an access database, however I have about 33 fields in the table for which I want to include about 25 of the fields when checking for duplicates. To further explain the table (called CollarData) has the first 25 fields which are imported from various text files, the other fields are more metadata fields such as importDate, importSource, and Duplicate Flag fields. I only want to check the first 25 fields when checking for duplicates. I want to add the "DUP" flag to a field called QAQC in the same table. I have been trying using various techniques for weeks but I can't seem to get the syntax right. Any help would be greatly appreciated. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-19 : 01:26:09
|
quote: Originally posted by Subarcticguy I am trying to do something similar in an access database, however I have about 33 fields in the table for which I want to include about 25 of the fields when checking for duplicates. To further explain the table (called CollarData) has the first 25 fields which are imported from various text files, the other fields are more metadata fields such as importDate, importSource, and Duplicate Flag fields. I only want to check the first 25 fields when checking for duplicates. I want to add the "DUP" flag to a field called QAQC in the same table. I have been trying using various techniques for weeks but I can't seem to get the syntax right. Any help would be greatly appreciated.
You've to post this in Access forum if you're looking at Access query------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|
|