Visual Studio’s External Tools – WIIFM

Most developers forget that it exists, and DBAs never even know that it’s there: Visual Studio’s External Tools (Menu > Tools > (your personalized Tools here). Here are just a few examples of database tasks that a DBA might want on the External Tools menu, to get you started:

1. Run SQLCMD with an existing .sql file

image_thumb7

Command: C:Program FilesMicrosoft SQL Server100ToolsBinnSQLCMD.EXE

Initial directory: In this example, chose $(SolutionDir) to show an example of using file at root of Solution

Arguments: These are sqlcmd arguments: –E (use trusted connection) –i input file

2. Run a selected Batch File

image_thumb9

Command: C:WindowsSystem32cmd.exe

Initial directory: In this example, chose $(ItemDir) to show an example of using the directory of the file that is currently selected in Solution Explorer

Arguments: The /c parameter “carries out the command specified by string and then terminates”. The $(ItemPath) says to use the file that is currently selected in Solution Explorer.

3. Run a Powershell script

image_thumb13

Command: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe

Initial directory: In this example, leave blank to show using an absolute path

Arguments: –ExecutionPolicy RemoteSigned to set the executionpolicy needed for the file being executed. The –file parameter points to the file being executed.

Reference for External Tools Arguments: http://msdn.microsoft.com/en-us/library/ekbzk5f8.aspx

Add a Comment

Your email address will not be published. Required fields are marked *