简体   繁体   中英

how to connect to servers in MS SQL Server Management Studio using windows credential in SQLCMD

I have multiple servers in my workspace I am trying to connect to and would like to make a single SQL script to do so. To connect to each server Windows Credentials are required and the option on the server is not set otherwise, nor do I have access to them lest I can convince of need.

Is it then possible to use the :Connect command to pass my windows credentials or can I only do so using SQL Server Authentication?

Thanks in advance.

By default, sqlcmd will use integrated authentication (Windows credentials). You can specify it using -E , as dsolimano mentioned, but it's unecessary.

By excluding the -U for username and -P for password switches, it's implied you wish to use your Windows credentials.

An example would be:

sqlcmd -S ServerName -i script.sql -o results.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM