SqlServer 08: Query to list all databases in an instance?

元气小坏坏 提交于 2019-12-04 15:32:01

问题


How do I list all the databases for a given sql server 08 instance using sqlcmd?


回答1:


sqlcmd -E -S SERVER\INSTANCE -Q "sp_databases"



回答2:


EXEC sp_databases

or

SELECT NAME FROM sys.sysdatabases

or

EXEC sp_msForEachDB 'PRINT ''?''';



回答3:


To elaborate with more detail for the sqlcmd newbie:

C:\> sqlcmd -S <the_server_name>
1> select name from sys.databases
2> go



回答4:


You can use sp_databases stored procedure.



来源:https://stackoverflow.com/questions/2087902/sqlserver-08-query-to-list-all-databases-in-an-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!