Tip: Executing OS Commands from OSQL or ISQL

Data Transformation Services (DTS) and SQL Agent provide powerful means of scripting complex jobs, but for simple OS-level batch file processing, OSQL and ISQL can quickly and effectively meet your needs. OSQL and ISQL can even execute OS commands when you begin the command sequence with double exclamation points (!!). For example, you can use the command

!! copy d:\temp\test.txt d:\temp\test2.txt

in an ISQL batch or interactive session to issue an OS-level copy command. This example is basic, but you could just as easily use the !! command sequence to execute an FTP session or a complex Windows Script Host (WSH) command file from an OSQL or ISQL session.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.