随笔-5  评论-7  文章-1  trackbacks-0

null

 

--如何得到一个数据库中每个表格的数据数目?

USE Forums -- 可改成您的数据库名称
SET NOCOUNT ON

DECLARE @tables_cursor CURSOR 7
set @tables_cursor=Cursor FOR
SELECT name FROM sysobjects WHERE type = 'U'
OPEN @tables_cursor
DECLARE @tablename varchar(30), @quote char(1)
SELECT @quote = ''''

FETCH NEXT FROM @tables_cursor INTO @tablename
WHILE (@@fetch_status <> -1)
BEGIN
EXEC ('Select ' + @quote+'Rows in ' + @tablename + ' = '+ @quote + ', count(*) from '+ @tablename)
FETCH NEXT FROM @tables_cursor INTO @tablename
END
DEALLOCATE @tables_cursor
SET NOCOUNT OFF
posted on 2005-11-06 01:08 轻舞flash 阅读(50) 评论(1) 编辑 收藏

评论:
#1楼 2008-04-03 11:42 | 路过[未注册用户]
写的好
我在网上看到类似就是运行不了
你的把”7“去掉,运行就没问题了

 回复 引用   

发即时信息给我

昵称:轻舞flash
园龄:6年4个月
粉丝:0
关注:1
<2005年11月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

搜索

 
 

常用链接

随笔分类

文章分类

相册