用户表肯定是有记录: select name AS 表名 from dbo.sysobjects WHERE xtype='U'
sql-server對根據系統表 sysindexes 里的統計信息進行查詢優化.1.----------更新所有表的統計信息 EXEC sp_updatestats 2.----------查找資料表名字及行數 select a.name, b.rows from sysobjects a, sysindexes b where a.id = b.id and a.xtype = 'U' and b.status = 18450
CA7180A2E(不求甚解) 能解释一下吗
取得用户表名: select name from sysobjects where objectproperty(id,'IsUserTable')=1或者select name from sysobjects where xtype='u' and status>0
我想得到db1数据库里的所有用户表,及每个表对应的记录条数。请问系统表里有记录吗。如果没有,怎么实现啊。 1.get user defined table select * from sysobjects where xtype='U'2.get user defined table records set nocount on declare @table_name varchar(100) declare @str varchar(1000)declare get_count cursor for select [name] from sysobjects where xtype='U'open get_countfetch next from get_count into @table_name while @@fetch_status=0 begin Print @table_name+' Total records :' select @str= 'select count(*) from '+ @table_name exec(@str) fetch next from get_count into @table_name endCLOSE get_count DEALLOCATE get_countgo
select a.name 表名,b.rows 记录数 from sysobjects a join sysindexes b on a.xtype='U' and a.status>0 and a.id=b.id and b.indid<2
select name AS 表名
from dbo.sysobjects WHERE xtype='U'
EXEC sp_updatestats 2.----------查找資料表名字及行數
select a.name, b.rows
from sysobjects a,
sysindexes b
where a.id = b.id
and a.xtype = 'U'
and b.status = 18450
能解释一下吗
select name
from sysobjects where objectproperty(id,'IsUserTable')=1或者select name from sysobjects where xtype='u' and status>0
1.get user defined table
select * from sysobjects where xtype='U'2.get user defined table records
set nocount on
declare @table_name varchar(100)
declare @str varchar(1000)declare get_count cursor for
select [name] from sysobjects where xtype='U'open get_countfetch next from get_count into @table_name
while @@fetch_status=0
begin
Print @table_name+' Total records :'
select @str= 'select count(*) from '+ @table_name
exec(@str)
fetch next from get_count into @table_name
endCLOSE get_count
DEALLOCATE get_countgo