简体   繁体   English

如何使用SQLCMD中的Windows凭据连接到MS SQL Server Management Studio中的服务器

[英]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.

相关问题 不在域上时,使用Windows凭据使用Management Studio连接到SQL Server - Connect to SQL Server with Management Studio using a Windows Credential while not on the domain 如何使用MS Server Management Studio和ODBC连接到MS SQL数据库 - How to connect to a MS SQL database using MS Server Management Studio and ODBC 如何使用SQL Server Management Studio使用Windows和SQL身份验证连接到SQL Server - How to connect to SQL Server using SQL Server Management Studio using Windows and SQL Authentication 如何在Windows 8中安装MS SQL Server 2008管理工作室? - how to instal MS SQL Server 2008 management studio in windows 8? 无法使用NHibernate登录到SQL Server,但使用Management Studio或sqlcmd可以正常工作 - Cannot login to SQL Server using NHibernate, but with Management Studio or sqlcmd it works 使用Windows身份验证使用Management Studio连接到SQL Server - Connect to SQL Server with Management Studio using Windows Authentication 在 SQL Server Management Studio 中,什么是 SQLCMD 模式? - In SQL Server Management Studio what is SQLCMD mode? 查询在SQL Server Management Studio中运行,但不在sqlcmd中运行 - Query runs in SQL Server Management Studio but not in sqlcmd 在MS SQL Server Management Studio中使用LIKE - Using LIKE in ms sql server management studio 如何在 SQL Server Management Studio 中注册 SQL Server 服务器? - How to register SQL Server servers in SQL Server Management Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM