Is there any way I could find out programmaticaly what databases exist on a server? It's because I would like to show user all available databases and allow him to choose the one he's interested in.
有什么方法可以找出programmaticaly服务器上存在哪些数据库?这是因为我想向用户显示所有可用的数据库,并允许他选择他感兴趣的数据库。
5 个解决方案
#1
If you mean, "Which databases are on a specific instance of SQL Server", then the stored procedure sp_databases
(accessible via Master) will help you.
如果您的意思是“哪个数据库位于特定的SQL Server实例上”,那么存储过程sp_databases(可通过Master访问)将对您有所帮助。
#2
use Microsoft.SqlServer.Management.Smo, it lets you query for servers and databases, specifically when you call SmoApplication.EnumAvailableSqlServers().
使用Microsoft.SqlServer.Management.Smo,它允许您查询服务器和数据库,特别是在调用SmoApplication.EnumAvailableSqlServers()时。
#3
- 2k5:
select * from sys.databases
- 2k:
select * from sysdatabases
2k5:从sys.databases中选择*
2k:从sysdatabases中选择*
#4
Would depend on which database you were referring to. Each db has their own way of querying these meta info.
取决于您所指的数据库。每个数据库都有自己的方式来查询这些元信息。
#1
If you mean, "Which databases are on a specific instance of SQL Server", then the stored procedure sp_databases
(accessible via Master) will help you.
如果您的意思是“哪个数据库位于特定的SQL Server实例上”,那么存储过程sp_databases(可通过Master访问)将对您有所帮助。
#2
use Microsoft.SqlServer.Management.Smo, it lets you query for servers and databases, specifically when you call SmoApplication.EnumAvailableSqlServers().
使用Microsoft.SqlServer.Management.Smo,它允许您查询服务器和数据库,特别是在调用SmoApplication.EnumAvailableSqlServers()时。
#3
- 2k5:
select * from sys.databases
- 2k:
select * from sysdatabases
2k5:从sys.databases中选择*
2k:从sysdatabases中选择*
#4
Would depend on which database you were referring to. Each db has their own way of querying these meta info.
取决于您所指的数据库。每个数据库都有自己的方式来查询这些元信息。
#5
See Three Way To List All Databases On Your Server
请参阅列出服务器上所有数据库的三种方法