USE 选的库 select name from sysobjects where type = 'U'
大哥这个sysdatabase是查询数据库的,那查询数据表的了?
(1) 从master库里面选择到数据库 : select * from master.dbo.sysdatabases where dbid>4(2) 从 sysobjects 表获取 表 select * from 数据库.dbo.sysobjects WHERE type='U' 如: select * from Northwind.dbo.sysobjects WHERE type='U'
表是在自己的数据库里面取 select name from sysobjects where xtype='U'
可以从master库里面选择到数据库select name from dbo.sysdatabases这样就可以选出所有的数据库如果要选择非系统数据库,可以加上dbid>4
正解,楼主可以研究一下SQL Server中的master数据库中的系统表,这就是传说中的数据字典。很多软件也都是这么做的。顺便提一句,不同的数据库,数据字典不一样,要注意。
SELECT NAME FROM SYSDATABASES
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
select name
from sysobjects
where type = 'U'
从master库里面选择到数据库 :
select * from master.dbo.sysdatabases where dbid>4(2)
从 sysobjects 表获取 表
select * from 数据库.dbo.sysobjects WHERE type='U' 如:
select * from Northwind.dbo.sysobjects WHERE type='U'
select name from sysobjects where xtype='U'