使用Visual Studio 2008编辑SQL查询 [英] Editing SQL query with Visual Studio 2008

查看:113
本文介绍了使用Visual Studio 2008编辑SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请向我推荐使用Visual Studio 2008 Professional编辑SQL查询的最佳方法吗?

Would you recommend me the best approach to edit SQL query with Visual Studio 2008 Professional, please?

我知道我可以从Server Explorer的上下文菜单中打开查询窗口并在 SQL窗格中编辑文本。但不幸的是,我不允许将查询保存到文件中,并且查找和替换命令在那里不起作用。

I know I can open Query window from context menu in Server Explorer and edit text in SQL Pane. But unfortunately I am not allowed to save query to a file and Find and Replace commands are not working there.

或者,我可以在Visual Studio编辑器中打开扩展名为.SQL的文本文件,以获得语法突出显示和完整的编辑功能,但是却失去了执行脚本的可能性。

Alternatively I can open text file with extension .SQL in Visual Studio editor obtaining syntax highlighting and full editing capabilities but losing possibility to execute the script.

现在,我将查询文本从一个窗口复制到另一个窗口,然后又返回,但我希望有更好的解决方案。

Now I copy query text from one window to another and back but I hope there is better solution.

非常感谢您的建议!

推荐答案

如果在Visual Studio中的解决方案中创建数据库项目,则可以为该项目设置默认的数据库连接。然后,可以针对该连接执行数据库项目中包含的任何* .sql文件。我通常要做的是选择要执行的文本,然后右键单击它,然后选择运行选择。

If you create a Database project within your solution in Visual Studio, then you can set up a default database connection for that project. Then any *.sql files that are included in the database project can be executed against that connection. What I usually do is select the text to be exectued and right-click it, then select "Run Selection".

您可以在以下位置设置任意数量的数据库连接解决方案资源管理器中的数据库引用节点,然后选择要对其执行查询的数据库。

You can set up any number of database connections under the "Database References" node in the solution explorer, and choose the one you want to run your query against.

这篇关于使用Visual Studio 2008编辑SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆