I am trying to figure out how to "test for connectivity" to a SQL Server database from DOS. If the connection fails I need to detect the failure.
sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS
You'll notice that that command doesn't return a true/false value. Also, if the instance doesn't exist, it times out. I want something like this that doesn't have a "timeout" issue that makes the user wait:
if ( connectivity exists to local ) (
setup DSN for local
) else (
setup DSN for local\SQLEXPRESS
)
Strangely, osql.exe -L doesn't work for me even though I do have a listening instance.