visual-studio Visual Studio - 在现有 SSMS 窗口中使用 SQL Management Studio 打开 SQL 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2193083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:31:02  来源:igfitidea点击:

Visual Studio - Open a SQL file with SQL Management Studio in an existing SSMS window?

sqlsql-servervisual-studio

提问by Todd Menier

I'm using Visual Studio 2008 and SQL Server 2008. I would like .sql files in my VS projects to open in SQL Management Studio by default. No problem so far: I right-click the file, Open With, Add SSMS, and set it as the default. What I don't like is that it opens a new instance of SSMS every time, and I would like it to open in an existing instance if there is one.

我使用的是 Visual Studio 2008 和 SQL Server 2008。我希望我的 VS 项目中的 .sql 文件默认在 SQL Management Studio 中打开。到目前为止没问题:我右键单击该文件,打开方式,添加 SSMS,并将其设置为默认值。我不喜欢的是它每次都会打开一个新的 SSMS 实例,如果有的话,我希望它在现有实例中打开。

I noticed that the Open command associated with .sql files in Windows (which has the behavior I want) calls ssms.exe with the /dde switch. Not exactly sure what switch does, but I played around with it and it doesn't seem to have anything to do with opening files in an existing instance.

我注意到与 Windows 中的 .sql 文件关联的 Open 命令(具有我想要的行为)使用 /dde 开关调用 ssms.exe。不完全确定 switch 的作用,但我玩过它,它似乎与在现有实例中打开文件没有任何关系。

Any idea how I can get this behavior to work from within Visual Studio?

知道如何让这种行为在 Visual Studio 中发挥作用吗?

Thanks in advance!

提前致谢!

回答by Nikolay Hidalgo Diaz

Right click the .sql file within Visual Studio, then click "open with", then click "add..." in "Open with" dialog. In the "add program" dialog type "explorer.exe" into the program name field and somehting into "firendly name" field e.g. "with explorer", then click ok. Then select "with exlorer" in "Open with" dialog and click "set as default". Now VS will open .sql files with explorer wich will in its turn call SSMS.

在 Visual Studio 中右键单击 .sql 文件,然后单击“打开方式”,然后在“打开方式”对话框中单击“添加...”。在“添加程序”对话框中,在程序名称字段中输入“explorer.exe”,然后在“友好名称”字段中输入一些内容,例如“with explorer”,然后单击“确定”。然后在“打开方式”对话框中选择“使用资源管理器”并单击“设置为默认值”。现在 VS 将使用资源管理器打开 .sql 文件,它将依次调用 SSMS。

Normally if you open 2 different .sql fiels in explorer you get them in a single SSMS window. If it still opens 2 ssms windows, you need to correct the registry (HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command, replace /dde with %1)

通常,如果您在资源管理器中打开 2 个不同的 .sql 文件,您会在一个 SSMS 窗口中获得它们。如果它仍然打开2个ssms窗口,则需要更正注册表(HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command,将/dde替换为%1)

回答by QuangKha

Right - click on C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe file -> Properties ->Go to Compability Tab-> Uncheck all the checkbox.

右键单击C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe file -> Properties ->转到Compability Tab-> 取消选中所有复选框。

Rerun SQL Management Tool.

重新运行 SQL 管理工具。

回答by Marco Alves

I am using SQL Server Management Studio 2012 Express and I have made this to work by pointing "Program" to "explorer.exe"

我正在使用 SQL Server Management Studio 2012 Express,并且通过将“程序”指向“explorer.exe”来使其工作

This is how my register is set up: "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe" /dde

这是我的寄存器的设置方式:“C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe”/dde

at

HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Open\Command

HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Open\Command

folder.

文件夹。