34,594
社区成员
发帖
与我相关
我的任务
分享
declare @oldcount int
set @oldcount=1000
declare @newcount int,@sql nvarchar(4000)
set @sql='select @a=rows from sysindexes where id = object_id(''trans_normal'') and indid in (0,1)'
exec sp_executesql @sql,N'@a int output',@newcount output
if(@newcount>@oldcount)
begin
declare @a int
set @a=@newcount - @oldcount
set @sql= 'select top ' + @a + ' * From trans_normal'
print @sql
end
set @sql= 'select top ' + ltrim(@a) + ' * From trans_normal'