亚洲韩日午夜视频,欧美日韩在线精品一区二区三区,韩国超清无码一区二区三区,亚洲国产成人影院播放,久草新在线,在线看片AV色

您好,歡迎來到思海網絡,我們將竭誠為您提供優質的服務! 誠征網絡推廣 | 網站備案 | 幫助中心 | 軟件下載 | 購買流程 | 付款方式 | 聯系我們 [ 會員登錄/注冊 ]
促銷推廣
客服中心
業務咨詢
有事點擊這里…  531199185
有事點擊這里…  61352289
點擊這里給我發消息  81721488
有事點擊這里…  376585780
有事點擊這里…  872642803
有事點擊這里…  459248018
有事點擊這里…  61352288
有事點擊這里…  380791050
技術支持
有事點擊這里…  714236853
有事點擊這里…  719304487
有事點擊這里…  1208894568
有事點擊這里…  61352289
在線客服
有事點擊這里…  531199185
有事點擊這里…  61352288
有事點擊這里…  983054746
有事點擊這里…  893984210
當前位置:首頁 >> 技術文章 >> 文章瀏覽
技術文章

六種SQL Server數據庫刪除數據庫重復行實用方法

添加時間:2012-6-5  添加: admin 

SQL Server刪除重復行是我們最常見的操作之一,下面就為您介紹六種適合不同情況的SQL Server刪除重復行的方法,供您參考。

1.如果有ID字段,就是具有唯一性的字段

delect   table   where   id   not   in   (        select   max(id)   from   table   group   by   col1,col2,col3...      )      group by 子句后跟的字段就是你用來判斷重復的條件,如只有col1,那么只要col1字段內容相同即表示記錄相同。

2. 如果是判斷所有字段也可以這樣

select   *   into   #aa   from   table   group   by   id1,id2,....      delete   table        insert   into   table        select   *   from   #aa  3. 沒有ID的情況

select   identity(int,1,1)   as   id,*   into   #temp   from   tabel      delect   #   where   id   not   in   (      select   max(id)   from   #   group   by   col1,col2,col3...)      delect   table      inset   into   table(...)      select   .....   from   #temp  4. col1+','+col2+','...col5 聯合主鍵

select   *   from     table   where   col1+','+col2+','...col5   in   (      select   max(col1+','+col2+','...col5)   from   table        where   having   count(*)>1      group   by   col1,col2,col3,col4        )   group by 子句后跟的字段就是你用來判斷重復的條件,如只有col1,那么只要col1字段內容相同即表示記錄相同。

5.

select   identity(int,1,1)   as   id,*   into   #temp   from   tabel      select   *   from     #temp   where   id   in   (      select   max(id)   from   #emp   where   having   count(*)>1   group   by   col1,col2,col3...)     6.

select   distinct   *   into   #temp   from   tablename        delete   tablename        go      insert   tablename   select   *   from   #temp   Sqlclub    go      drop   table   #temp 

關鍵字:SQL Server、刪除、重復行

分享到:

頂部 】 【 關閉
版權所有:佛山思海電腦網絡有限公司 ©1998-2024 All Rights Reserved.
聯系電話:(0757)22630313、22633833
中華人民共和國增值電信業務經營許可證: 粵B1.B2-20030321 備案號:粵B2-20030321-1
網站公安備案編號:44060602000007 交互式欄目專項備案編號:200303DD003  
察察 工商 網安 舉報有獎  警警  手機打開網站