isqlw Utility

Command Prompt Utilities

Command Prompt Utilities

isqlw Utility

The isqlw utility (SQL Query Analyzer) allows you to enter Transact-SQL statements, system stored procedures, and script files. You can set up shortcuts or create batch files to launch a preconfigured SQL Query Analyzer.

Syntax

isqlw     [-?] |
    [
        [-S server_name[\instance_name]]
        [-d database]
        [-E] [-U user] [-P password]
        [{-i input_file} {-o output_file} [-F {U|A|O}]]
        [-f file_list]
        [-C configuration_file]
        [-D scripts_directory]
        [-T template_directory]
    ]

Arguments

-?

Displays usage information.

-S server_name[\instance_name]:

Specifies the instance of Microsoft® SQL Server™ 2000 to connect to. Specify server_name to connect to the default instance of SQL Server 2000 on that server. Specify server_name\instance_name to connect to a named instance of SQL Server 2000 on that server. If no server is specified, isqlw connects to the default instance of SQL Server on the local computer. This option is required when executing isqlw from a remote computer on the network.

-d database

Issues a USE database statement when isqlw is started. The default is the default database of the user.

-E

Uses a trusted connection instead of requesting a password.

-U user

Is the user login ID. Login IDs are case-sensitive.

-P password

Is the login password. The default is NULL.

-i input_file

Identifies the file that contains a batch of SQL statements or stored procedures. The –i and –o options must be specified together. When -i and -o options are specified, queries in the input file are executed and results are saved in the output file. No user interface is shown while the queries are executing. When execution is completed, the process exits.

-o output_file

Identifies the file that receives output from isqlw. The –i and –o options must be specified together. When -i and -o options are specified, queries in the input file are executed and results are saved in the output file. No user interface is shown while the queries are executing. When execution is completed, the process exits. If file format is not specified with -F, the output file will be of the same type as the input file.

-F {U|A|O}

Is the format of the input and output files. Values include Unicode, ANSI, and OEM. If -F is not specified, automatic mode is used (if the file is Unicode signed, the file is opened as Unicode; otherwise, the file is opened as ANSI).

-f file_list

Loads the listed files into SQL Query Analyzer. With the -f option, you can load one or more files (file names separated by single space). If more than one file is specified, files are opened on the same connection context. The file name can include the directory path where the file resides. Wildcard characters, such as the asterisk (*), as in C:\Test\*.sql, can be used.

-C configuration_file

Uses the settings specified in the configuration file. Other arguments explicitly specified on the command prompt overwrite the corresponding configuration file settings.

-D scripts_directory

Overwrites the default saved script directory specified in the registry or the configuration file specified with -C. The value does not persist in the registry or the configuration file. To see the current value of this option in SQL Query Analyzer, click Tools, and then click Options.

-T template_directory

Overwrites the default template directory specified in the registry or the configuration file specified with -C. The value does not persist in the registry or the configuration file. To see the current value of this option in SQL Query Analyzer, click Tools, and then click Options.

Remarks

The isqlw utility can be used with or without a user interface. To run isqlw without a user interface, specify valid login information (an instance of SQL Server 2000 with a trusted connection or a valid login ID and password) and input and output files. isqlw executes the contents of the input file and saves the results in the output file.

If input and output files are not specified, isqlw runs interactively, starting the SQL Query Analyzer. If valid login information is specified, isqlw connects directly an instance of SQL Server 2000. If not enough information is specified to connect, the Connect to SQL Server dialog box appears.

isqlw and SQL Query Analyzer use the ODBC API. The utility uses the Microsoft® SQL Server ODBC driver default settings for SQL-92. For more information, see Effects of SQL-92 Options.

For more information about this utility, see Getting Started with Command Prompt Utilities.

Examples
A. Execute SQL statements

This example connects to MyServer (pubs database) and executes SQL statements from input_file and stores the results of the execution in output_file.

isqlw -S MyServer -d pubs -U sa -P -i input_file -o output_file

B. Use wildcards

This example loads all .sql files into SQL Query Analyzer. All connections use Windows Authentication and point to the pubs database on the local server.

isqlw -d pubs -E -f "c:\Program Files\Microsoft SQL Server\MSSQL\Install\*.sql"

C. Load multiple files

This example loads two files into SQL Query Analyzer. It uses Windows Authentication to connect to the local server.

isqlw -d pubs -E -f "c:\Program Files\Microsoft SQL Server\MSSQL\Install\instpubs.sql" "c:\Program Files\Microsoft SQL Server\MSSQL\Install\instcat.sql"
D. Use Unicode files

This example connects to the pubs database on MyServer using Windows Authentication and executes the Input.sql file. The results are saved in the Output.txt file. The files are opened as Unicode files.

isqlw -S MyServer -d pubs -E -i input.sql -o output.txt -FU