Export (0) Print
Expand All

isql Utility

SQL Server 2000

  New Information - SQL Server 2000 SP3.

The isql utility allows you to enter Transact-SQL statements, system procedures, and script files; and uses DB-Library to communicate with Microsoft® SQL Server™ 2000.

Syntax

isql
    
[-?] |
    [-L] |
    [
        {
            {-U login_id [-P password]}
            | –E
        }
        [-S server_name] [-H wksta_name] [-d db_name]
        [-l time_out] [-t time_out] [-h headers]
        [-s col_separator] [-w column_width] [-a packet_size]
        [-e] [-x max_text_size]
        [-c cmd_end] [-q "query"] [-Q "query"]
        [-n] [-m error_level] [-r {0 | 1}]
        [-i input_file] [-o output_file] [-p]
        [-b] [-O]
    ]

Arguments

-?

Displays the syntax summary of isql switches.

-L

Lists the locally configured servers and the names of the servers broadcasting on the network.

-U login_id

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

-P password

Is a user-specified password. If the -P option is not used, isql prompts for a password. If the -P option is used at the end of the command prompt without any password, isql uses the default password (NULL).

Security Note  NULL passwords are not recommended.

Passwords are case-sensitive.

The ISQLPASSWORD environment variable allows you to set a default password for the current session. Therefore, you do not have to hard code a password into batch files.

If you do not specify a password with the -P option, isql first checks for the ISQLPASSWORD variable. If no value is set, isql uses the default password, NULL. The following example sets the ISQLPASSWORD variable at the command prompt and then accesses the isql utility:

C:\>SET ISQLPASSWORD=abracadabra
C:\>isql 

Security Note  To mask your password, do not specify the -P option along with the -U option. Instead, after specifying isql along with the -U option and other switches (do not specify -P), press ENTER, and isql will prompt you for a password. This method ensures that your password will be masked when it is entered.

-E

Uses a trusted connection instead of requesting a password.

-S server_name

Specifies the default instance of SQL Server to connect to. isql does not support connecting to a named instance of SQL Server 2000. If no server is specified, isql connects to the default instance of SQL Server on the local computer. This option is required if you are executing isql from a remote computer.

-H wksta_name

Is a workstation name. The workstation name is stored in sysprocesses.hostname and is displayed by sp_who. If not specified, the current computer name is assumed.

-d db_name

Issues a USE db_name statement when isql is started.

-l time_out

Specifies the number of seconds before an isql login times out. If no time_out value is specified, a command runs indefinitely. The default time-out for login to isql is eight seconds.

-t time_out

Specifies the number of seconds before a command times out. If no time_out value is specified, a command runs indefinitely; the default time-out for logging in to isql is eight seconds.

-h headers

Specifies the number of rows to print between column headings. The default is to print headings one time for each set of query results. Use -1 to specify that no headers will be printed. If using -1, there must be no space between the parameter and the setting (-h-1, not -h -1).

-s col_separator

Specifies the column-separator character, which is a blank space by default. To use characters that have special meaning to the operating system (for example, | ; & < >), enclose the character in double quotation marks (").

-w column_width

Allows the user to set the screen width for output. The default is 80 characters. When an output line has reached its maximum screen width, it is broken into multiple lines.

-a packet_size

Allows you to request a different-sized packet. The valid values for packet_size are 512 through 65535. The default value for the Microsoft Windows NT® version of isql is 8192; otherwise, the default value is 512 for Microsoft MS-DOS®, although larger sizes can be requested with that version as well. Increased packet size can enhance performance on larger script execution where the amount of SQL statements between GO commands is substantial. Microsoft testing indicates that 8192 is typically the fastest setting for bulk copy operations. A larger packet size can be requested, but isql defaults to 512 if the request cannot be granted.

-e

Echoes input.

-x max_text_size

Specifies, in bytes, the maximum length of text data to return. Text values longer than max_text_size are truncated. If max_text_size is not specified, text data is truncated at 4096 bytes.

-c cmd_end

Specifies the command terminator. By default, commands are terminated and sent to SQL Server 2000 by entering GO on a line by itself. When you reset the command terminator, do not use Transact-SQL reserved words or characters that have special meaning to the operating system, whether preceded by a backslash or not.

-q "query"

Executes a query when isql starts, but does not exit isql when the query completes. (Note that the query statement should not include GO). If you issue a query from a batch file, you can use %variables. Environment %variables% also work. For example:

SET table = sysobjects
isql /q "Select * from %table%"

Use double quotation marks around the query and single quotation marks around anything embedded in the query.

-Q "query"

Executes a query and immediately exits isql when the query completes. Use double quotation marks around the query and single quotation marks around anything embedded in the query.

-n

Removes numbering and the prompt symbol (>) from input lines.

-m error_level

Customizes the display of error messages. The message number, state, and error level are displayed for errors of the specified severity level or higher. Nothing is displayed for errors of severity levels lower than the specified level. Use -1 to specify that all headers are returned with messages, even informational messages. If -1 is used, there must be no space between the parameter and the setting (-m-1, not -m -1).

-r {0 | 1}

Redirects message output to the screen (stderr). If you do not specify a parameter, or if you specify 0, only error messages with severity 11 or higher are redirected. If you specify 1, all message output (including "print") is redirected.

-i input_file

Identifies the file that contains a batch of SQL statements or stored procedures. The less than (<) comparison operator can be used in place of -i.

-o output_file

Identifies the file that receives output from isql. The greater than (>) comparison operator can be used in place of -o.

-p

Prints performance statistics.

-b

Specifies that isql exits and returns a DOS ERRORLEVEL value when an error occurs. The value returned to the DOS ERRORLEVEL variable is 1 when the SQL Server error message has a severity of 10 or greater; otherwise, the value returned is 0. MS-DOS batch files can test the value of DOS ERRORLEVEL and handle the error appropriately.

-O

Specifies that isql reverts to the behavior of earlier versions. These features are deactivated:

  • EOF batch processing

  • Automatic console width scaling

  • Wide messages

    This option also sets the default DOS ERRORLEVEL value to -1.

Show:
© 2014 Microsoft