查询数据库中所有表的行数(sqlserver 2000)
create proc ss
as
set nocount on
create table TableSpace
(
TableName varchar(50),
RowsCount char(11),
Reserved varchar(18),
Data varchar(18),
Index_size varchar(18),
Unused varchar(18)
)
declare @sql varchar(500)
declare @TableName varchar(50)
DECLARE @ObjOwner varchar(50)
declare Cursor1 Cursor
for
select NAME,(SELECT name FROM sysusers su WHERE su.uid=so.uid) AS objOwner from sysobjects so where xtype='U'
open Cursor1
fetch next from Cursor1 into @TableName,@ObjOwner
while @@fetch_status = 0
begin
set @sql = 'insert into TableSpace '
set @sql = @sql + ' exec sp_spaceused '''+ @ObjOwner + ''+'.'+''+ @TableName + ''' '
PRINT @sql
exec (@sql)
fetch next from Cursor1 into @TableName,@ObjOwner
end
close Cursor1
deallocate Cursor1
select tableName,rowscount from TableSpace where tableName<>'TableSpace'
drop table TableSpace
go
exec ss
DROP PROC ss
?
方法二: select 表名=a.name,記錄數=b.rows??from sysobjects a,sysindexes b
where a.name=b.name and? a.type='u'
轉載于:https://www.cnblogs.com/v888/archive/2012/06/04/2534622.html
總結
以上是生活随笔為你收集整理的查询数据库中所有表的行数(sqlserver 2000)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Job Processing 工序安排
- 下一篇: 关于黑客的报道里绝对不会提到的信息