码迷,mamicode.com
首页 > 数据库 > 详细

SQL:bat批处理多个.sql文件

时间:2014-07-28 14:35:03      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   strong   文件   io   for   

一、批处理文件 update.bat 
     设置sqlserver的实例
     记得一定要配置logfile文件

@echo off

:: #### B.01 database schema update for B.01 -> B.02 -> B.03 ####


set LOGFILE="D:\Forklift\B01_B02toB03_Schema_Update.log"


:: Tell user that the installation process is starting.
echo This script will upgrade the database schema from B.01 and or B.02 to B.03. Would you like to proceed with this update?

CHOICE /C YN

IF ERRORLEVEL 2 GOTO EOF

echo Installing the database updates ...

sqlcmd /S .\SQL2008 /Usa /PHola2008! /dmaster -i "Scripts/EnzoModifications.sql"  >> %LOGFILE% 2>&1
if /I %ERRORLEVEL% EQU 1 (
   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>&1
if /I %ERRORLEVEL% EQU 1 (
   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 ...   
  

 

二、将.sql 文件放置在同目录的Script文件夹下
   

DEMO下载地址:
http://files.cnblogs.com/gguozhenqian/SQLBat.zip

SQL:bat批处理多个.sql文件,布布扣,bubuko.com

SQL:bat批处理多个.sql文件

标签:style   blog   http   color   strong   文件   io   for   

原文地址:http://www.cnblogs.com/gguozhenqian/p/3872562.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!