SQL Azure - How can I select sysdatabases table from master database in SQL Azure?

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

In SQL Azure, I try this:

select * From master.dbo.sysdatabases

And get this error:

Reference to database and/or server name in 'master.dbo.sysdatabases' is not supported in this version of SQL Server

What should I do to be able to run that query in SQL Azure?

回答1:

You use the system view sys.databases (without the master qualification, it is not needed)

The system table sysdatabases has been deprecated since SQL Server 2005 (Azure is a later version) and in any case is not supported on Azure



回答2:

You are getting this error because you are running this statement from another database than master. You cannot add "master." to your statements unless you are already on the master database. More generally speaking, you cannot issue statements that execute a command on another database than the one you are on.

You can run the statement without the database qualification, and it will run, as gbn is suggesting. Or you can connect to master and execute it as-is.



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