top
100
from
table
where
key
not
in
(select
top
100
key
from
table)
大概想法是,用括号中的语句将最上面的100行找出来,然后用not
in排除掉,这样一来虽然是找的top100
但是因为已经排除了100行所以就是第100行到200行了。select from tabel1 where filed01 in (select filed01 fromtabel1
group by filed01
having count(filed01 )>1)
说明:filed01 为有重复字段的列
group by dname
这是sqlserver 实现的,不知道符不符合。不过刚刚验证了一下,不是很对,估计是主键的原因,修改好了再看看
以上语句只能测试出部分,这个存储过程可以实现全部,sqlserver直接执行即可:
create table #temp(Recordcount int ,tableName varchar(30))
declare @tablename varchar(30)
declare @sql varchar(100)
declare @str varchar(30)
declare tablecursor cursor for
select name from sysobjects where xtype='u'
open tablecursor
fetch next from tablecursor into @tablename
while @@fetch_status=0
begin
set @str=@tablename
set @sql='insert into #temp(recordcount,tablename) select count(),'+''''+@tablename+''''+' from '+@tablename
exec(@sql)
fetch next from tablecursor into @tablename
end
close tablecursor
deallocate tablecursor
select from #temp drop table #temp
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)