- 论坛徽章:
- 0
|
你需要的信息是沒有什麼意義的
DB的大小可以通過文件屬性得到字節數.
你想知道一個DB有多少筆資料對你很有用嗎, 有的記錄字段很多, 有的記錄字段很少, 請問你以什麼樣的標準來衡量呢, 每個 TABLE 的結構都不同, 而且存儲的數據也不一樣, 怎麼可以相加呢,即使加出來也只是數量.
你可以使用 sysobjects 系統表查出所有的用戶表 [xtype] = \'U\' , 然後每個表執行一下, 如下面的語句:
create table [#temp]([CNT] numeric(20))
insert [#temp] values(0)
declare @name sysname,@s nvarchar(1000)
declare [cursor_test] cursor for select [name] from sysobjects where [xtype]=\'U\' order by [name]
open [cursor_test]
fetch next from [cursor_test] into @name
while @@fetch_status<>-1
begin
select @s=\'declare @cnt int\'
select @s=@s+char(13)+char(10)+\'select @cnt=0\'
select @s=@s+char(13)+char(10)+\'select @cnt=count(*) from [\'+ltrim(rtrim(@name))+\']\'
select @s=@s+char(13)+char(10)+\'select @cnt=isnull(@cnt,0)\'
select @s=@s+char(13)+char(10)+\'update [#temp] set [CNT]=[CNT]+@cnt\'
exec (@s)
fetch next from [cursor_test] into @name
end
close [cursor_test]
deallocate [cursor_test] |
|