What is the best way to check database access from remote machine.
Here is the situation:
-
SQL Server 2005 (or 2008) is running on
MACHINE1(Windows 2003 or 2008). There is a database calledENTERPRISEDB. -
Another server, called
MACHINE2(Windows 2003 or 2008). It has ODBC connection toMACHINE1.
Now, what is the best and simplest SQL query to check if MACHINE2 can connect and access the ENTERPRISEDB in MACHINE1?
Thanks.
If your ODBC connection is to database ENTERPRISEDB then you could run
which will return “1” if the database exists or nothing if it doesn’t.
If you need a boolean/int return then try
which will return “1” if it exists, “0” if it doesn’t.