百度空间 | 百度首页 
 
查看文章
 
SQL数据库所有表数据量统计[原]
2009年06月08日 星期一 17:43

这个其实不算原创的,是网友闲心"游僧 问我的一个SQL问题,解决了,感觉挺有意思就贴上来了。

declare @tableName varchar(30)
declare @tableRowCount int
declare @strSql varchar(320)
declare @ResultTable table(rowsCount int, tablesName varchar(40))
declare @strCount varchar(100)
declare myCur cursor for (select name from sys.objects where type='U')
open myCur
fetch next from myCur into @tableName
while @@fetch_status = 0
    begin
   set @strSql=' select COUNT(*) as tCOUNT,'''+@tableName+''' as tableName from '+ @tableName
--   exec(@strSql)
   insert into @ResultTable exec(@strSql)
   fetch next from myCur into @tableName
end
close myCur
deallocate myCur
select * from @ResultTable;


类别:asp.net+sql+c#||oracle | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu