Declare @sTblName varchar(128) Declare @iRecCount Int Declare @strsql Nvarchar(500) --注意修改了数据类型 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 @iRecCount=Count(*) from ' +@sTblName exec sp_executesql @strsql,N'@iRecCount Int out',@iRecCount out /* 加上自己的处理代码 */ Fetch Next From Cursor1 Into @sTblName End Close Cursor1 Deallocate Cursor1
Declare @sTblName varchar(128)
Declare @iRecCount Int
Declare @strsql Nvarchar(500) --注意修改了数据类型 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 @iRecCount=Count(*) from ' +@sTblName
exec sp_executesql @strsql,N'@iRecCount Int out',@iRecCount out
/* 加上自己的处理代码 */
Fetch Next From Cursor1 Into @sTblName
End Close Cursor1
Deallocate Cursor1