1 删除表中重复的数据,但保留重复数据中的一条
delete from kk_attachs where (attachguid) in
(select attachguid from kk_attachs group by attachguid
having count(attachguid) >1)
and row_id not in (select min(row_id) from kk_attachs group by attachguid having count(*)>1)
2 删除数据库数据时,自增长列的值未自动重置
DBCC CHECKIDENT(表名,RESEED,0)
3 批量删除表,最简单的方式
------1、首先明确一点,sys.tables 这张表是sqlserver的用户表,即我们自己新建的表,这里查出所有数据,也可以加条件
select * from sys.tables
------2、上面既然可以查出所有的表,那么我们也可以利用这一点制造sql语句
select 'drop table ' + name + ';' from sys.tables
------3、上面的查出来后,如下效果,这里的table_1、table_2为实际要删除的表,直接复制执行这些sql语句就行了
drop table table_1;
drop table table_2;
...
Your exemplary work demonstrates remarkable potential. With strategic enhancements, this foundation can be transformed into a pioneering contribution that advances the field and solidifies your position as an industry authority.