rem 将当前目录下的所有 *.SQL文件 执行一次,并将结果输出文件 rem for循环执行SQL命令文件 echo =======Begin=========== for %%i in (*.sql) do ( sqlcmd -A -S LOCALHOST -U SA -P yourpassword -i D:\SQL\IN\%%i -o D:\SQL\OUT\%%i @echo FileName %%i ) echo =======end ============ pause
DAC模式登陆SQL SERVER 2012 批量执行SQL 脚本文件。
CMD命令执行显示结果:
D:\SQL\in>(
sqlcmd -A -S LOCALHOST -U SA -P yourpassword -i D:\SQL\IN\Usp_SF_FC04012.sql -o D
:\SQL\OUT\Usp_SF_FC04012.sql
)
FileName Usp_SF_FC04012.sql
D:\SQL\in>(
sqlcmd -A -S LOCALHOST -U SA -P yourpassword -i D:\SQL\IN\Usp_U8M_RemoveEntity.sq
l -o D:\SQL\OUT\Usp_U8M_RemoveEntity.sql
)
FileName Usp_U8M_RemoveEntity.sql
D:\SQL\in>echo =======end ============
=======end ============
--批量生成 SQL脚本文件
echo off rem for循环创建文件 echo ============== for %%i in (Usp_CP_MoRoutingLoadCal,Usp_CP_RccpProcess, Usp_CP_RrpProcess ) do ( (echo EXEC UFDATA_2012.DBO.sp_DecryptObject '%%i' ,800000 echo GO ) >>d:\sql\in\%%i.sql ) echo ============== rem 显示时间 rem echo %date:~0,10% %time:~0,8% pause
标签:DAC,%%,sql,rem,echo,SQL,Usp,SERVER From: https://www.cnblogs.com/samrv/p/17635982.html