Kirk Marple

Musings of a Yukon and Whidbey pioneer... and feeling the arrows in my back...

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Subscriptions

Post Categories



Thursday, February 24, 2005 - Posts

Replacement for VS.NET "create command file"
During my Yukon/Whidbey testing, one the the bugs i filed was that "Create Command File" was missing from the VS.NET IDE.

I'd found this to be a useful helper, where it would create a command file (.cmd) from the SQL scripts in my database project.

In the November CTP, there's no support for database projects, but they've also said that "Create Command File" has been removed.

This was somewhat of a pain, since there's really no good way to execute directories of scripts easily.

So, today i decided to finally whip together a little .cmd file of my own that would recurse thru a directory path, and run 'osql' on the scripts in there.

Whew! What a relief... finally an easy way to zip thru all my scripts and update all the stored procedures at once.

@echo off
REM: Usage: RunScripts [Path] [Server] [Database]

if '%1' == '' goto usage
if '%2' == '' goto usage
if '%3' == '' goto usage

if '%1' == '/?' goto usage
if '%1' == '-?' goto usage
if '%1' == '?' goto usage
if '%1' == '/help' goto usage

ECHO Path: %1
ECHO Server: %2
ECHO Database: %3

for /r %1 %%f in (*.sql) DO osql -S "%2" -d "%3" -E -b -i "%%f"

goto finish

REM: How to use screen
:usage
echo.
echo Usage: RunScripts Server Database
echo Server: the name of the target SQL Server
echo Database: the name of the target database
echo.
echo Example: RunScripts Path MainServer MainDatabase
echo.
echo.
goto done

REM: finished execution
:finish
echo.
echo Script execution is complete!
:done
pause
@echo on

posted Thursday, February 24, 2005 11:59 AM by kmarple with 2 Comments




Powered by Dot Net Junkies, by Telligent Systems