Method of batch execution of SQL files through Osql/ocmd batches in SQL Server _mssql

Source: Internet
Author: User

batch execution of SQL files with Osql/ocmd batch

Note: In the above illustration we can see that osql does not support all the features of SQL Server 2008, and if you need to use all of the features of SQL Server 2008, you can use the Ocmd command.

With the Osql/ocmd command to bulk Execute SQL files, of course, you need to write a batch command, such as we execute the above SQL file can be written in txt the following statement:

Copy Code code as follows:

Osql-s "127.0.0.1"-u "sa"-P "sa"-D "Northwind"-i "%cd%/1.sql"
Osql-s "127.0.0.1"-u "sa"-P "sa"-D "Northwind"-i "%cd%/2.sql"

Then save into Sql.bat with the top 1.sql and 2.sql placed under the same file, double-click Sql.bat on execution.

Related Article

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.