Microsoft KB Archive/76784

= INF: Operating System Commands and Control of Flow in ISQL or OSQL =

Article ID: 76784

Article Last Modified on 2/14/2005

-

APPLIES TO


 * Microsoft SQL Server 4.21a Standard Edition
 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 6.5 Service Pack 1
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 7.0 Service Pack 1
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q76784



SUMMARY
ISQL and OSQL can issue can issue operating system commands by starting a line with two exclamation points (!!) followed by the command. However, these commands are unconditionally run when encountered by ISQL or OSQL and they cannot take part in the Transact-SQL control-of-flow language.



MORE INFORMATION
For example, if a file called TEST.SQL is created with the following contents

if 1=2 !!dir c:\config.sys select &quot;One equals two&quot;

then the operating system command specified on the second line will always be run by ISQL, even though the command is apparently inside an IF control-of-flow condition. Note that the SELECT statement is part of the control of flow and will not be run in this case because 1=2 evaluates to FALSE. When running the following

ISQL /U /P /S /itest.sql

the output that might be returned is:

1> 2> The volume label in drive C is GIZMO. The Volume Serial Number is 16AA:6729 Directory of C:\

CONFIG  SYS     2054   9-10-91  11:52a 1 File(s)  28319744 bytes free

2> 3>

Additional query words: Windows NT

Keywords: KB76784

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.