简体   繁体   English

可以配置sqlcmd.exe路径吗?

[英]Can sqlcmd.exe path be configured?

I want to change the location of sqlcmd.exe from its default place to my desired one. 我想将sqlcmd.exe的位置从默认位置更改为我想要的位置。 Can I place it in my project directory for example? 我可以将它放在我的项目目录中吗?

您可以创建一个.bat文件,将工作目录更改为所需的路径,然后将收到的参数传递给sqlcmd.exe。

Try move Resources (it is in same dir where sqlcmd.exe is) folder and sqlcmd.exe together. 尝试将Resources (它与sqlcmd.exe所在的dir相同)文件夹和sqlcmd.exe一起移动。 My guess sqlcmd.exe using resources from that folder. 我猜sqlcmd.exe使用该文件夹中的资源。

Fraz, I have tested the following, and it works fine: Fraz,我测试了以下内容,它运行正常:

Remove both SQLCMD.exe and SQLCMD.rll from their current folders and place them in the directory you'd like to run SQLCMD.exe from. 从当前文件夹中删除SQLCMD.exeSQLCMD.rll ,并将它们放在您要运行SQLCMD.exe的目录中。 The RLL file is, by default, found in the Tools\\Binn\\Resources folder of the Microsoft SQL Server Program Files folder. 默认情况下,RLL文件位于Microsoft SQL Server程序文件文件夹的Tools \\ Binn \\ Resources文件夹中。 These are the only two files that are required for SQLCMD.exe to work, and the RLL file doesn't have to be in a Resources folder in the new location (it can be in the same directory as SQLCMD.exe). 这些是SQLCMD.exe工作所需的唯一两个文件,RLL文件不必位于新位置的Resources文件夹中(它可以与SQLCMD.exe位于同一目录中)。

Once you have done the above, you must add the new location to the Path Environment Variable in Windows. 完成上述操作后,必须将新位置添加到Windows中的“ 路径环境变量”。 On Windows 7, you can access the Environment Variables dialog by navigating to Control Panel\\System and Security\\System , clicking on Advanced system settings , and pressing Environment Variables on the Advanced tab of the resulting dialog box. 在Windows 7上,您可以通过导航到“ 控制面板”\\“系统”和“安全\\系统” ,单击“ 高级系统设置” ,然后在结果对话框的“ 高级”选项卡上按“ 环境变量”来访问“环境变量”对话框。 Once in that dialog, look for the Path variable, under the System variables heading; 进入该对话框后,在System variables标题下查找Path变量; once you've found that, select it, click Edit , and add the new location of SQLCMD.exe to the end of the current value in the Variable value box, preceding it with a semicolon. 找到后,选择它,单击“ 编辑” ,然后将SQLCMD.exe的新位置添加到“ 变量值”框中当前值的末尾,并在其前面加上分号。

Please let me know if you would like anything explained further or you have any questions about this answer. 如果您想要进一步解释,或者您对此答案有任何疑问,请与我们联系。 I could help you find the Environment Variables dialog on other versions of Windows, if you'd like. 如果您愿意,我可以帮助您在其他版本的Windows上找到“环境变量”对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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