echo off
echo "正在进行数据库安装，请稍候******"
MSDERelA\setup4.exe
echo "数据库安装完成，正在进行附加数据库操作，请稍后******"

sc config MSSQLSERVER start= auto
sc failure MSSQLSERVER reset= 1 actions= restart/1000

sc config SQLSERVERAGENT start= auto
sc failure SQLSERVERAGENT reset= 1 actions= restart/1000

net start MSSQLSERVER
net start SQLSERVERAGENT

cd D:\tiandi\syjxc_odbc_setup
copy D:\tiandi\syjxc_odbc_setup\date1\syjxc_Data.mdf E:\msde\dataMSSQL\Data\syjxc_Data.mdf /y
copy D:\tiandi\syjxc_odbc_setup\date1\syjxc_log.LDF E:\msde\dataMSSQL\Data\syjxc_log.LDF /y
copy D:\tiandi\syjxc_odbc_setup\date1\syjxc_temp_Data.mdf E:\msde\dataMSSQL\Data\syjxc_temp_Data.mdf /y
copy D:\tiandi\syjxc_odbc_setup\date1\syjxc_temp_log.LDF E:\msde\dataMSSQL\Data\syjxc_temp_log.LDF /y

osql -U sa -P sa -S"127.0.0.1" -Q"sp_attach_db 'syjxc' , 'E:\msde\dataMSSQL\Data\syjxc_Data.MDF','E:\msde\dataMSSQL\Data\syjxc_Log.LDF'"
osql -U sa -P sa -S"127.0.0.1" -Q"sp_attach_db 'syjxc_temp' , 'E:\msde\dataMSSQL\Data\syjxc_temp_Data.MDF','E:\msde\dataMSSQL\Data\syjxc_temp_Log.LDF'"

go

echo "数据库附加成功"
pause
exit 