Batch command to run Query (Store Procedure), atau aplikasi DOS yang bisa kita gunakan untuk mengeksekusi query yang kita simpan bisa berupa store procedure atau select statement. Batch command ini bisa kita jalankan dengan menggunakan schedule baik daily, weekly, dll, dan hasil run batch command bisa kita simpan dalam file log text.
Selamat mencoba !!!!
REM Perintah ini untuk Eksekusi Store Procedure melalui Batch Command dan disimpan dalam file logBatch command diatas akan menjalankan query yang disimpan dalam [filename_to_exec_query]
REM Ubah [UserId], [Password], [ServerName]filename_query , [dbName] and [ [UserId] ]
REM Contoh : osql -U[Password] -P [ServerName] -S [dbName] -d osql -U -i .\ [filename_to_exec_query]
REM
CLS
:: variables to create log
set drive="C:\[FolderName]\[LogFileName_First] "
SET dateNtime="%date:~10,4%%date:~4,2%%date:~7,2%-%time:~0,2%%time:~3,2%"
rem "Fri 03/12/2010---------10:37:26.27"
echo "*******************************" >> %drive%(%dateNtime%).txt
date /t >> %drive%(%dateNtime%).txt
time /t >> %drive%(%dateNtime%).txt
echo
echo "*** Begin Store Procedure ***" >> %drive%(%dateNtime%).txt
echo
[UserId] [Password] -P [ServerName] -S [dbName] -i .\[filename_to_exec_query] -d ******************************* >> %drive%(%dateNtime%).txt
echo
echo "*** End Store Procedure ***" >> %drive%(%dateNtime%).txt
echo
date /t >> %drive%(%dateNtime%).txt
time /t >> %drive%(%dateNtime%).txt
echo "" >> %drive%(%dateNtime%).txt
echo "===============================" >> %drive%(%dateNtime%).txt
EXEC [store_procedure_name]
@Variabel1 = 6,
@Variabel2 = 4
Selamat mencoba !!!!
Comments
Post a Comment