The following query doesn't list all the databases in the server
Posted on 2016-09-06
The following query:
DECLARE @command varchar(1000)
select @command = 'USE ?; select DB_NAME(), default_schema_name
order by default_schema_name
EXEC sp_MSforeachdb @command
Doesn't list all the database on the server I am running it on. I do get a one error message: Msg 911, Level 16, State 1, Line 1
Database 'Chris21PROD' does not exist. Make sure that the name is entered correctly.
How do make the query list all the databases in the server, any assistance is appreciated?