每个副本更新一个重复的条目 [英] updating duplicate entries by one for each duplicate
问题描述
HI
我的一张桌子有问题。
我最初使用其他桌子的窗帘标准更新它。
由于这些标准,这些记录随后创建了重复的条目。我无法将其链接起来并更改标准,所以我需要和替代它。
基本上当我选择记录时,他们返回的屁股如下:
HI
I have a problem with one of my tables.
I originally update it using curtain criteria from another table.
these records then created duplicate entries due to these criteria. I cant link it back up and change the criteria, so I need and alternative to this.
basically when i select the records, they return ass follows :
ID | Name | Amount |
1 Jake 2100
1 Kim 450
1 Jake 2100
1 Henry 410
所以我想运行一个脚本这将更新任何重复记录的ID以返回以下内容:
so i want to run one script that will update the id of any duplicate records to return the following :
ID | Name | Amount
1 Jake 2100
2 Kim 450
3 Jake 2100
4 Henry 410
任何建议?
考虑到必须首先选择1然后相应更新
any advice?
take into consideration that ill have to first select the "1's" and then update accordingly
推荐答案
试试这个
Hi,
Try this
ALTER TABLE TableName
ADD ID2 INT IDENTITY
update TableName set Id=id2
ALTER TABLE TableName
DROP COLUMN ID2
希望这能帮到你
it hope this will help you
这篇关于每个副本更新一个重复的条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!