笔记160 删除重复记录没有大小关系时,处理重复值中的方法

笔记160 删除重复记录没有大小关系时,处理重复值中的方法

 1 --删除重复记录没有大小关系时,处理重复值中的方法一
 2 --链接:http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html
 3 --3、删除重复记录没有大小关系时,处理重复值中的方法一
 4 USE tempdb
 5 
 6 IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'#A表') AND type in (N'U'))
 7 DROP TABLE #A表
 8 
 9 CREATE TABLE  #A表
10 ([intType] int,[name] varchar(4),[int3] int)
11 insert #A表
12 select 0,'张三',2 union all
13 select 99,'张三',0 union all
14 select 0,'李四',2 union all
15 select 99,'李四',1 union all
16 select 99,'王五',1 union all
17 select 99,'赵六',0 union all
18 select 0,'赵六',0 union all
19 select 99,'X',0 union all
20 select 0,'Y',0
21 
22 
23 if object_id('Tempdb..#') is not null
24     drop table #
25 Select distinct * into # from #A表--排除重复记录结果集生成临时表#
26 
27 truncate table #A表--清空表
28 
29 insert #A表 select * from #    --把临时表#插入到表#T中
30 
31 select * from #A表

 

posted @ 2013-08-03 23:32  桦仔  阅读(477)  评论(0编辑  收藏  举报