select 部記錄數=sum(rows) from (select id,rows=max(rows)  from sysindexes group by id)a

解决方案 »

  1.   


    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
      

  2.   

    非常感谢两位, 尤其是zjcxc(邹建) 大哥的帮助!!