exec sp_dboption yourDBName,'select into/bulkcopy',true;
go
select distinct * into #temp from yourTable;
go
truncate table yourTable;
go
insert into yourTable select * from #temp;
go
select distinct * into #temp from yourTable;
go
truncate table yourTable;
go
insert into yourTable select * from #temp;
解决方案 »
- 求助T-SQL语句
- 日期转换的问题,谢谢各位。
- SQL合并查询问题
- 存储过程的限制
- 我怎么把一个表的记录总数赋给一个变量???
- 将表table_a中的字段fieldA、fieldB、fieldC的内容写入table_B中字段fieldA、fieldB、fieldC,应该怎样写??
- 急~~~,排序规则冲突,怎样从另一台服务器上restore所有数据库?
- sql server2000 中的标识有两种,一个是‘不用于复制’,是什么意思呢?
- 急!关于XMl数据类型到SQL Server数据类型转换的问题
- 怎么样实现如下的sql?谢谢!
- access中的记录操作问题
- 请问有谁知道如何把用友的数据转换成EXECL表的形式
select distinct * into #t1 from table1
delete from table1
insert into table1 (collist) select * from #t1
go
select distinct * into newTable from yourTable;
go
drop table yourTable;
go
exec sp_rename 'newTable','yourTable'
create table abc (A char(2),B char(2),C char(2))--如下两条记录
insert abc values("a1","b1","c1")
insert abc values("a1","b1","c2")想得到如下结果a1,b1,c1
SELECT A,B,MIN(C) From TableName GROUP BY A,B找出相同记录:
SELECT A,B
FROM abc
GROUP BY [a], [a]
HAVING Count([A])>1 And Count([A])>1
select yourKey1,yourKey2..
from yourTable
group by yourKey1,yourkey2..
having count(oneofyourkey)>1
GROUP BY [a], [b]
HAVING Count([A])>1 And Count([b])>1
go
select distinct * into newtable from tablename
go
truncate table tablename
go
insert tablename
insert * from newtable
go
drop table newtable
go
--如果原来select into/bulkcopy设置为false
--exec sp_dboption yourDBName,'select into/bulkcopy',false
--go