Using the osql Utility

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Using the osql Utility

The osql utility is a Microsoft® Win32® command prompt utility for ad hoc, interactive execution of Transact-SQL statements and scripts. To use osql, users must understand Transact-SQL.

The osql utility is typically used in these ways:

  • Users interactively enter Transact-SQL statements in a manner similar to working on the command prompt. The results are displayed in the command prompt window.

  • Users submit an osql job either specifying a single Transact-SQL statement to execute or pointing the utility to a text file that contains Transact-SQL statements to execute. The output is usually directed to a text file, but it also can be displayed in the command prompt window.

The osql utility uses the ODBC database application programming interface (API). It is a replacement for the isql command prompt utility based on the DB-Library API. Both utilities are provided with Microsoft SQL Server™ 2000. The DB-Library API remains at a SQL Server 6.5 level; therefore, applications that depend on DB-Library, such as isql, do not support some SQL Server 2000 features. For example, isql cannot access columns defined with the ntext data type and truncates any char, varchar, nchar, or nvarchar columns longer than 255 bytes. It also cannot retrieve results as XML documents. Except for these limitations in isql, both osql and isql support the same features. For more information about features not supported by isql, see Connecting Early Version Clients to SQL Server 2000.

See Also

isql Utility

osql Utility