Embedding SQL script within a batch script is just as easy. The following batch script
executes itself in SQL context. The trick is the GOTO command in the first line of the script.
When executing GOTO START in batch context than the command processor will jump to the label ":START"
and execute the batch script. The batch script will then run the OSQL.EXE using the batch file itself
as SQL file argument to be executed.
When subsequently executing the GOTO START line in SQL context, the query language processor will jump
to the label "START:" and execute the SQL queries.
In fact the file can be opened and executed in Query Analyzer as is, since the batch script in the file looks
like a comment to the query language processor. |