sql server 2005 如何删除前几条记录或重复记录

--创建测试表
create table dbo.t1
(
c int identity(1,1) not null,
name varchar(10) null
)

insert into dbo.t1 values('guoqiang')

select * from t1



--删除前3行
select top(3) * from dbo.t1
delete top(3) from dbo.t1

--删除重复记录
declare @count int
select @count =count(*) from dbo.t1 where name = 'guoqiang'
delete top(@count-1) from  dbo.t1 where name = 'guoqiang'
  
 

你可能感兴趣的:(SQL,Server,开发和管理)