Sql:bat batch processing of multiple. sql files

Source: Internet
Author: User
Tags goto

One, batch file Update.bat
Set up an instance of SQL Server
Make sure to configure the logfile file

@echo off:: # # # # # B. on Database Schema Update  forB. on  -B. Geneva  -B.Geneva ####SetLOGFILE="D:\Forklift\B01_B02toB03_Schema_Update.Log":: TellUserthat the installation process isStarting.echo This script would upgrade theDatabase Schema  fromB. on  and orB. Geneva  toB.Geneva. Would like  toProceed withThisUpdate? CHOICE/C YNIFERRORLEVEL2 GOTOEofecho Installing theDatabaseupdates ... sqlcmd/S. \sql2008/Usa/phola2008!/Dmaster-I "Scripts/Enzomodifications.sql ">> %LOGFILE% 2>&1if /I%ERRORLEVEL%EQU1(Echo[%date%%time%]Error Running "Enzomodifications.sql">> %LOGFILE% 2>&1   Goto: FAILURE) echo[%time%]"Enzomodifications.sql" was successfully applied.>> %LOGFILE%Echo[%time%]"Enzomodifications.sql" was successfully applied ... sqlcmd/S. \sql2008/Usa/phola2008!/Dmaster-I "Scripts/Sxdel_sxreindex.sql ">> %LOGFILE% 2>&1if /I%ERRORLEVEL%EQU1(Echo[%date%%time%]Error Running "Sxdel_sxreindex.sql">> %LOGFILE% 2>&1   Goto: FAILURE) echo[%time%]"Sxdel_sxreindex.sql" was successfully applied.>> %LOGFILE%Echo[%time%]"Sxdel_sxreindex.sql" was successfully applied ...

Ii. Place the. sql file under the Script folder in the same directory
   

DEMO:
Http://files.cnblogs.com/gguozhenqian/SQLBat.zip

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.