统计库中所有表的记录数
Declare @iRecCount Int
Declare @strsql varchar(255)
declare @sTblName varchar(255)
Declare Cursor1 Cursor For Select Name From SysObjects where xType='U'
Order By Name
Open Cursor1
Fetch Next From Cursor1 Into @sTblName
While @@Fetch_Status=0
Begin
Set @strsql='Select Count(*) as '+@sTblName+' from ' +@sTblName
exec (@strsql)
/* 加上自己的处理代码 */
Fetch Next From Cursor1 Into @sTblName
End
Close Cursor1
Deallocate Cursor1