When you open the SQL Server Management studio you connect to the Database engine through UI.I want same functionality through SQL query e.g. to connect to database we write Use similarly is there any way to connect to database engine.
Connect to Database Engine through query
7.7k Views Asked by meetjaydeep At
2
In SQL Server Management Studio, you cannot connect to a server using server name, database name, user id and password from a query.
What you need to do is go to the
Object Explorer
, click onConnect
and thenDatabase Engine
:Once you're connected to a server, you can switch between databases using
but you cannot connect to another server in a T-SQL query, as far as I know.