您现在的位置是:网站首页> 编程资料编程资料
sql2000数据库清除重复数据的二种方法_MsSql_
2023-05-26
439人已围观
简介 sql2000数据库清除重复数据的二种方法_MsSql_
使用游标实现
复制代码 代码如下:
declare @id1 int,@oldid int,@e_REcordid int ,@Olde_REcordid int
DECLARE price CURSOR
FOR SELECT id ,E_recordId FROM evaeve order by E_recordId desc
OPEN price
FETCH NEXT FROM price into @oldid,@Olde_REcordid
while @@fetch_status = 0
begin
FETCH NEXT FROM price
into @id1,@e_REcordid
if @Olde_REcordid=@e_REcordid
BEGIN
delete from evaeve where id=@id1
end
set @oldid=@id1
set @Olde_REcordid=@e_REcordid
end
close price
DEALLOCATE price
使用sql语句实现
复制代码 代码如下:
delete from evaeve where id not in( select max(id) from evaeve group by E_RecordID)
您可能感兴趣的文章:
相关内容
- 使用正则表达式匹配tsql注释语句_MsSql_
- 二种sql分页查询语句分享_MsSql_
- bak文件怎么打开 2000w数据怎么打开?_MsSql_
- MSSQL附加数据库拒绝访问提示5120错误的处理方法_MsSql_
- SQL-ORDER BY 多字段排序(升序、降序)_MsSql_
- sql 取代游标的写法示例_MsSql_
- sqlserver、mysql获取连接字符串步骤_MsSql_
- SqlServer修改数据库文件及日志文件存放位置_MsSql_
- SQL Server降权运行 SQL Server 2000以GUESTS权限运行设置方法_MsSql_
- SQL Server 分页查询通用存储过程(只做分页查询用)_MsSql_