DB operations-Execute SQL statements with batch processing

Source: Internet
Author: User
Tags odbc

Use batch processing to invoke the query parser in the command line state to execute the statements in this SQL file. The following is an explanation of the Query Analyzer (ISQLW) command-line arguments in SQL Server Help: The isqlw utility (SQL Query Analyzer) enables you to enter Transact-SQL statements, system stored procedures, and script files. You can start a preconfigured SQL Query Analyzer by setting a shortcut or creating a batch file.

1. Syntax
isqlw
    [-?] |
     [
[-sserver_name[instance_name]]
[-D database]
[- E] [-u user] [-p password]
[{-I input_file} {-ooutput_file} [-F {u| a| O}]]
[-F file_list]
[-c Configuration_file]
[-D scripts_directory]
[-t template_directory]
     ]

2. Parameters
-?

Displays usage information.

-S Server_name[instance_name]:

Specifies the Microsoft®sql server™2000 instance to connect to. Specifies the server_name that is used to connect to the default instance of SQL Server 2000 on the servers.

Specifies the server_nameinstance_name that is used to connect to the SQL Server 2000 named instance on the server. If you do not specify a server, ISQLW will connect to the default instance of SQL Server on the local computer. This option is required when performing isqlw from a remote computer on the network.

-D Database

When ISQLW is started, a use database statement is issued. The default value is the user's default database.

-E

Use a trusted connection without requesting a password.

-U user

User Login ID. Login IDs are case sensitive.

-p password

is the login password. The default setting is NULL.

-I. Input_file

Identifies a file that contains a batch of SQL statements or stored procedures. You must specify both the-I and-o options. If you specify the-I and-o options, the query in the input file is executed and

Saves the results to the output file. The user interface is not displayed during query execution. When execution is complete, the process exits.

-O output_file

Identifies the file that receives the output from ISQLW. You must specify both the –i and –o options. If the-I and-o options are specified, the query in the input file is executed and the knot

Saved to the output file. The user interface is not displayed during query execution. When execution is complete, the process exits. If the file format is not specified with-F, the output file uses the

The same type as the input file.

-F {u| a| O

is the format of the input file and the output file. Values include Unicode, ANSI, and OEM. If-f is not specified, automatic mode is used (if the file is marked in Unicode format, it is opened in Unicode format; otherwise, the file is opened in ANSI format).

-F File_list

Loads the listed files into SQL Query Analyzer. With the-f option, you can mount one or more files (filenames separated by a single space). If multiple files are specified

, the files are opened with the same connection context. A file name can contain the directory path where the file resides. Wildcard characters, such as asterisks in c:test*.sql, can be used

(*)。

-C Configuration_file

Use the settings specified in the configuration file. Other parameters that are explicitly specified at the command prompt override the settings in the corresponding configuration file.

-D Scripts_directory

Overrides the default storage script directory specified in the registry or in a configuration file specified with –C. The value is not persisted in the registry or in the configuration file. To view the current value of this option in SQL Query Analyzer, click the Tools menu, and then click Options.

-T Template_directory

Overrides the default template directory specified in the registry or in a configuration file specified with –C. The value is not persisted in the registry or in the configuration file. To view the current value of this option in SQL Query Analyzer, click the Tools menu, and then click Options.


3. Notes

You can use the ISQLW utility when you have a user interface or no user interface. To run ISQLW without a user interface, specify valid logon information (instance of SQL Server 2000 with a trusted connection or a valid login ID and password) and input and output files. ISQLW will execute the contents of the input file and save the results to the output file. If no input and output files are specified, isqlw runs interactively and starts SQL Query Analyzer. If a valid logon information is specified, ISQLW will connect directly to the SQL Server 2000 instance. If you specify insufficient connection information, the Connect to SQL Server dialog box appears. ISQLW and SQL Query Analyzer use the ODBC API.
The utility uses the SQL-92 The default settings for the Microsoft®sql Server ODBC driver. < example >A The Execute SQL statement This example uses Windows authentication to connect to the pubs database on MyServer and executes the Input.sql file. The results are saved in Output. TXT file. These files are opened in Unicode file mode. isqlw-s myserver-d pubs-e -I input. Sql-o output.txt-fuB . Use the wildcard into example to load two files into SQL Query Analyzer. You will use Windows authentication to connect to the on-premises server. isqlw-d pubs-e-F"C:Program FilesMicrosoft SQL servermssqlinstallinstpubs.sql" "C:Program filesmicrosoftsql Servermssqlinstallinstcat.sql"C. Load multiple Files This example will all. SQL files are loaded 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 FilesMicrosoft SQL servermssqlinstall*.sql"D. Using Unicode files This example connects to the MyServer (pubs database)and executes the SQL statements in Input_file, and the execution results are stored in output_file. isqlw-s myserver-d pubs-u sa-p-i input_file-o output_file

DB operations-Execute SQL statements with batch processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.