ISQL script to create a database (SQL Server2000)

Source: Internet
Author: User

@ Echo off
Echo the following commands will set up the database for doccomposer.

Set/P pdbname = Please enter database name to be created: (Note: I do not know how to pass this parameter into createdb. SQL and doccomposerdatabase. in the SQL script, this parameter is invalid, and the parameter in the script is dead .)
Set/P phost = enter the host name (MACHINE) for database:
Set/P ppass = enter the password for "sa" User:

Echo if the database does not exist, it will be created, otherwise, the database will be updated and all the data will be removed !!

Echo enter Ctrl + C to stop, otherwise press any key to continue to set up the database.
Pause

Echo check or create the database
ISQL-s "% phost %"-U sa-P "% ppass %"-I createdb. SQL-O logs \ test1.log
Type logs \ test1.log> logs \ setup. Log

Pause

Echo create the tables...
ISQL-s "% phost %"-U sa-P "% ppass %"-I doccomposerdatabase. SQL-O logs \ test2.log
Type logs \ test2.log> logs \ setup. Log

Pause

Del logs \ test1.log
Del logs \ test2.log

Echo the database has been setup successfully.

 

××××××××××××××××××××××××××××××××××××××××××× ××××××

Appendix: parameters of the iSQL command in sqlserver

You are using a Windows Account to log on to the ms SQL Server on your PC. Please use iSQL-e
Assume that ntuser1 of the Windows Account needs to log on to the ms SQL Server.
1. log in to Windows2000 Professional with the NT account ntuser1, not the ms SQL Server.
2. iSQL-S server-e
Ii. SQL Server account:
1. Set authentication to SQL Server and windows.
2. iSQL-u login_id-P password-S server 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 prepare _end] [-Q "query"] [-Q "query"]
[-N] [-M error_level] [-r {0 | 1}]
[-I input_file] [-O output_file] [-p] [-B] [-O]-?
Displays the syntax Summary of the iSQL switch.
-L lists the names of the Servers configured locally and the servers broadcast on the network.
-U login_id: User Logon ID. The logon ID is case sensitive.
-P password is the password specified by the user. If not
-P option. iSQL prompts you to enter the password. If the-P option is used at the end of the command prompt without a password, iSQL uses the default password NULL ).
The password is case sensitive. The isqlpassword environment variable allows you to set the default password for the current session. Therefore, you do not need to use hard encoding
Set the password in the batch file. If no password is specified for the-P option, iSQL first checks the isqlpassword variable. If not set
Value. iSQL uses the default password (null ). In the following example, set the lpassword variable in the Command instructions and access the iSQL utility: C: \>
Set isqlpassword = abracadabrac: \> iSQL-e use a trusted connection without asking for a password.
-S SERVER_NAME
Specify the default SQL server instance to connect. ISQL does not support connection to SQL Server 2000 named instances. If no service is specified
ISQL connects to the default instance of SQL server on the local computer. If you want to execute iSQL from a remote computer on the network, you must
This option.
-H wksta_name is the workstation name.
The workstation name is stored in sysprocesses. hostname and displayed by sp_who. If not specified, the current computer name is used.
-D db_name: A use db_name statement is issued when iSQL is started.
-L time_out specifies the number of seconds before iSQL logon times out.
If the time_out value is not specified, the command runs indefinitely. The default timeout value for logging on to iSQL is 8 seconds.
-T time_out specifies the number of seconds before the command times out.
If the time_out value is not specified, the command runs indefinitely. The default timeout value for logging on to iSQL is 8 seconds.
-H headers specifies the number of rows to be printed between column headers.
By default, the title is printed once for each query result set. Use-1 to specify that the title is not printed. If-1 is used, it cannot be empty between parameters and settings.
Grid
(Can be-h-1, cannot be-h-1 ).
-S col_separator specifies the column delimiter, which is a space by default.
To use a character (for example, |; &) that has a special meaning on the operating system, use double quotation marks.
-W column_width allows you to set the screen output width. The default value is 80 characters. When the output line reaches the maximum screen width, it is split
Multiple rows.
-A packet_size allows you to request data packets of different sizes.
The valid value of packet_size is between 512 and 65535. In Microsoft Windows NT, the default iSQL value is 8192.
; In addition, the default iSQL value in Microsoft MS-DOS is 512, but you can also request larger packets in this version. Data
The increase in the package size can improve the performance of script execution. In such execution, the number of SQL statements between go commands is very important. Microsoft
The test shows that 8192 is the typical fastest setting for large-capacity replication operations. A larger packet size can be requested, but if the request cannot be batch
ISQL is 512 by default.
-E echo input.
-X max_text_size specifies the maximum length of the returned text data, in bytes.
Text values longer than max_text_size are truncated. If max_text_size is not specified, text data is truncated at 4096 bytes.
-C termination _end specifies the command Terminator.
By default, the command is terminated by entering go in a single line and sent to SQL Server 2000. When the reset command ends, no
Use the reserved characters or characters of the transact-SQL statements with special meanings on the operating system, regardless of whether there is a backslash before them.
-Q "query" executes the query When iSQL is started, but does not exit iSQL when the query is complete.
(Note that the query statement should not contain go ). If you issue a query from a batch file, use % variables. Environment % variables % is also acceptable
. For example:
Set table = syso B j e c tsisql/Q "select * from % table %" Double quotation marks are used for the query.
Use single quotes.
-Q "query": executes the query and immediately exits iSQL when the query is complete.
Double quotation marks are used for the query, and any content embedded in the query is enclosed by single quotation marks.
-N: Delete the number and prompt symbol (>) from the input line ).
-M error_level: Display custom error information.
Displays the number, status, and error level of a specified or higher severity error. Do not display any messages with errors with severity levels lower than the specified severity levels
. Use-1 to specify that all headers are returned together with messages, even information messages. If-1 is used, there cannot be
Space
(It Can Be-M-1, not-m-1 ).
-R {0 | 1} redirects the message output to the screen (stderr ).
If no parameter is specified or the specified parameter is 0, only 17 or higher error messages are redirected.
If the parameter is set to 1, all messages (including "print") will be redirected ").
-I input_file identifies the files that contain a batch of SQL statements or stored procedures. The less than () comparison operator can be used to replace-o. -P print performance statistics.
-B indicates that iSQL exits when an error occurs and a DOS errorlevel value is returned.
When the SQL server error message severity level is 10 or higher, the value returned to the DOS errorlevel variable is 1; otherwise, the returned value is
0. A MS-DOS batch file can test the DOS errorlevel value and handle errors as appropriate.
-O indicates that iSQL is restored to an earlier version. The following features are disabled: EOF batch processing console width auto-Adjusted Width Information
This option also sets the default value of DOS errorlevel to-1.

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.