Use csql as an external tool in Visual Studio

The most simple way to use csql in Visual Studio is to configure it as an external tool. Using the steps described here you can manage the command parameters in a file located in your solution root directory. Scripts are executed by choosing the configured tools menu item. All output and error messages will go into an output pane of the IDE.

Click the Menu Item Tools → External Tools…


In a default Visual Studio installation the following dialog appears:


In the external tools dialog press the Add Button.

Enter a title for the tool. In the Command field enter the path of csql.exe. In this sample we want to use a argument file that is expected in the current solution directory. So, in the Arguments field enter the option -cf $(SolutionDir)csqlargs.txt. Because the command should always execute the script currently open in the editor we add the option -i $(ItemPath).

In the field Initial Directory enter the text $(ItemDir). This will allow us to use relative paths in the script #include directives.

To get the output into a pane of Visual Studio also enable the check box option Use Output Window.

After entering all data the dialog should look like the following screen shot:


Don't forget to add the configuration/parameter file to your Solution root directory. In this example it is named csqlargs.txt. Its content may look like the following example:
; -----------------------------------------------------------------------------------------
; CSQL test configuration file.
; ----------------------------------------------------------------------------------------


Last edited May 28, 2010 at 1:43 PM by SqlService, version 2


No comments yet.