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