Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Application of the row_number () function of MSSQL sql server 2005x2008-delete the weight in the table

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Transferred from: http://www.maomao365.com/?p=4942

* * the function of the row_number function in the database is to generate a number for each row according to certain rules. We often use this attribute to paginate the table. Below we will describe the use of the row_number function to delete duplicate data rows in the table * * / build the table * / create table A (keyId int,info varchar (200)) go / * generate data * / insert into A (keyId,info) values (1), (2)), (3)), (4), (5), (1)), (1)), (21)), (31)), (4) 'd'), (51d'), (51d`), (1meme'), (6memricib1'), (7recollection C1'), (4memricid000'), (10memricimaomao365.com') go/* deletes several other * / delete [A2] from (select row_number () over (Partition By keyId order by keyId) as keyId2 in keyId duplicated data. * from A) as [A2] where [A2]. KeyId2 > 1 / * / * delete the other * / delete [A2] from (select row_number () over (Partition By keyId,info order by keyId) as keyId2,* from A) as [A2] where [A2] .keyId2 > 1 * / / * Show the deleted data * / select * from A gotruncate table A drop table A go

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report