Export (0) Print
Expand All

Using the osql Utility

SQL Server 2000

Using the osql Utility

  Topic last updated -- January 2004

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

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.

To use osql interactively or to build script files to be run using osql, users must understand Transact-SQL. The following sections of SQL Server Books Online document building Transact-SQL statements:

Section Description
Accessing and Changing Relational Data Overview Documents how to build Transact-SQL statements from individual syntax elements and to build multiple Transact-SQL statements into batches or scripts.
Creating and Maintaining Databases Overview Documents how to use Transact-SQL statements to create databases and all the data objects in a database. Also documents some database maintenance functions.
Administering SQL Server Overview Documents the administration tasks that can be performed on instances of SQL Server and SQL Server databases. The topic for each administration task indicates any Transact-SQL statement that can be used to perform the task.
Transact-SQL Overview This is the start of the Transact-SQL Reference, which documents the full syntax of every Transact-SQL statement.

Comparing the osql and isql Utilities

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

osql Utility

Running the osql Utility

Running Transact-SQL Statements Interactively Using osql

Running Transact-SQL Script Files Using osql

isql Utility

© 2015 Microsoft