开发者

Connect to Database Engine through query

开发者 https://www.devze.com 2023-03-03 08:39 出处:网络
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. t开发者_开发技巧o connect to database we write Usesimilarl

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. t开发者_开发技巧o connect to database we write Use similarly is there any way to connect to database engine.


What you are looking for is not supported - you need to provide the credentials in the Connect to Server dialogue.

There is no way to have a query window open a connection to a database directly.


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 on Connect and then Database Engine:

Connect to Database Engine through query

Once you're connected to a server, you can switch between databases using

USE (database name)

but you cannot connect to another server in a T-SQL query, as far as I know.

0

精彩评论

暂无评论...
验证码 换一张
取 消