SQL Server query to find all current database names

前端 未结 8 580
傲寒
傲寒 2020-12-03 09:34

I need a SQL query to find the names of existing databases.

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 10:10

    I don't recommend this method... but if you want to go wacky and strange:

    EXEC sp_MSForEachDB 'SELECT ''?'' AS DatabaseName'
    

    or

    EXEC sp_MSForEachDB 'Print ''?'''
    

提交回复
热议问题