views:

3182

answers:

4

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

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.

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.

Many thanks for suggestions!

+1  A: 

Wow you are right, this is a real pain. Would it be acceptable for you to use a local copy of the SQL Management Studio (the name might be wrong)? You would be outside of VS but you could still edit your query and run it at the same time. Definitely not optimal but better than nothing.

Good luck.

smaclell
+1  A: 

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.

Jeffrey L Whitledge
A: 

Check out this article on using database projects:

http://blog.reamped.net/post/2008/05/Using-Database-Projects-for-Visual-Studio.aspx

Tim Abell
+2  A: 

When I have to connect to Sql Server, I use NetBeans, as it has a number of features that make it much easier to use than Visual Studio. One of these is intellisense, which is very useful when you have an alias for a table name and lots of long field names. The general handling of connections and connection pools is also much cleaner in NetBeans. I could go on, but suggest trying it for yourself. You will almost certainly need the Sql Server jdbc driver, which can be downloaded from http://msdn.microsoft.com/en-us/data/aa937724.aspx

Thanks for information!
Alexander Prokofyev