-- 说明:只要修改use [db]中的数据库名即可; use [db] declare @count int declare @memberid nvarchar(50) -- 查询出要删除的蓝钻会员,将卡号保存到临时表; select distinct memberno into memberno_temp from membercard2blue where memberno not in(select memberno from membermanageblue) print '开始删除' -- 逐个删除; select @count = count(*) from memberno_temp while ( @count > 0 ) begin select top 1 @memberid = memberno from memberno_temp delete from membercard2blue where memberno = @memberid delete from memberno_temp where memberno = @memberid select @count = count(*) from memberno_temp end -- 删除临时表; drop table memberno_temp