[英]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. 我正在尝试连接到我的工作空间中的多个服务器,并希望创建一个SQL脚本来进行连接。 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. 要连接到每台服务器,需要Windows凭据,并且未在服务器上设置该选项,否则我也无权访问它们,以免我确信需要。
Is it then possible to use the :Connect command to pass my windows credentials or can I only do so using SQL Server Authentication? 然后可以使用:Connect命令来传递我的Windows凭据,还是只能使用SQL Server身份验证来传递?
Thanks in advance. 提前致谢。
By default, sqlcmd
will use integrated authentication (Windows credentials). 默认情况下, sqlcmd
将使用集成身份验证(Windows凭据)。 You can specify it using -E
, as dsolimano mentioned, but it's unecessary. 您可以使用-E
来指定它,如dsolimano所述,但这是不必要的。
By excluding the -U
for username and -P
for password switches, it's implied you wish to use your Windows credentials. 通过排除用于用户名的-U
和用于密码开关的-P
,这意味着您希望使用Windows凭据。
An example would be: 一个例子是:
sqlcmd -S ServerName -i script.sql -o results.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.