Rem batファイルSQL文を実行する例
@echo off
Rem 今の日付を取得する 格式:1810
set t=%date:~2,2%%date:~5,2%
Rem echo %t%
Rem sql文:update Table_1 set opter_flg = 5656 where tkey in (select t.tkey from Table_1 t where SUBSTRING(t.f1,charindex('-',t.f1)+1,4) = 1809)
set opterSQL=update Table_1 set opter_flg = 9999 where tkey in (select t.tkey from Table_1 t where SUBSTRING(t.f1,charindex('-',t.f1)+1,4) = %t%)
Rem echo %opterSQL%
set opterSQL2=update Table_2 set opter_flg = 9999 where tkey in (select t.tkey from Table_2 t where SUBSTRING(t.f1,charindex('-',t.f1)+1,4) = %t%)
osql -S"サーバ名" -d"DB名" -U"ユーザ" -P"パスワード" -Q"%opterSQL%;%opterSQL2%" -e
pause