--直接从系统表中查询的话--列出当前库中的所有用户表 select 表名=name from sysobjects where xtype='U' and status>=0 --列出当前库中的所有系统表 select 表名=name from sysobjects where xtype='S' --列出当前库中的所有视图 select 表名=name from sysobjects where xtype='V' --列出当前库中的所有用户视图 select 表名=name from sysobjects where xtype='V' and status>=0
select name from sysobjects where xtype='V'--视图名称
use pubs
go--列出系统表
EXEC sp_tables null, dbo, pubs, "'SYSTEM TABLE'"--列出用户表
EXEC sp_tables null, dbo, pubs, "'TABLE'"--列出视图
EXEC sp_tables null, dbo, pubs, "'VIEW'"
select 表名=name
from sysobjects
where xtype='U' and status>=0
--列出当前库中的所有系统表
select 表名=name
from sysobjects
where xtype='S'
--列出当前库中的所有视图
select 表名=name
from sysobjects
where xtype='V'
--列出当前库中的所有用户视图
select 表名=name
from sysobjects
where xtype='V' and status>=0