Skip to content Skip to sidebar Skip to footer

How To Query In A Specific Database On Azure?

I'm trying to execute a (very) simple query on Azure MSSql Server using PHP, but it does not work and prints the follow message: Warning: mssql_query(): message: Invalid object na

Solution 1:

You can't perform cross-database queries and, like the error message says, you also can't change database context using USE. If you want to query from multiple Azure databases, you need to connect to them independently with different connection strings.

Also, did you try specifying the database explicitly (and not connecting to [...].wondows.net:

[MyServerAtAzure]
host = mydatabase.database.windows.net
port = 1433
Database = myDatabase
tds version = 8.0
client_charset = UTF-8

And also properly prefixing your table with its schema?

$sql = "SELECT * FROM dbo.MyTable;";

Post a Comment for "How To Query In A Specific Database On Azure?"