Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL Bat

$
0
0

Please review batch file. I need to execute this file using sql authentication on sql server. And my log.log ,batch file, sql scripts on same folder location. Please give me advice for same. 

-----------------------------------------------------------------------------------------------------------------------------

@ECHO OFF
Cls
IF  "%1" == "" GOTO ERROR
IF  "%2" == "" GOTO ERROR
IF  "%5" == "" GOTO 4PARA
@echo on
:4PARA
:: predefined variables used throughout deployment
@set DBServer= servername,portnumber
@set LogFile=log.log
echo Process Started  %DATE% , %TIME%
echo Process Started  %DATE% , %TIME% > %LogFile%


echo #### Processing for OneGlobalSystem-ORGBR2013-DBUpdates-v001-v002.sql Started @ %DATE% %TIME% >> %LogFile%
SQLCMD -U xyz -P abc-S %DBServer% -d TEST-i Insert_Update_Delete_Select.sql -f 65001  >> %LogFile%
if %ERRORLEVEL% NEQ 0 GOTO ERROR1
echo Processing Ended @ %DATE% %TIME% ### >> %LogFile%
echo ------------------------------------------- >> %LogFile%

echo Process ended %DATE% , %TIME%
echo Process ended %DATE% , %TIME% >> %LogFile%
GOTO Return >> %LogFile%

:ERROR1
ECHO Error Raised
GOTO Return

:ERROR
ECHO.
ECHO.
ECHO To Run the Batch File, You need to Pass 4 Parameters
ECHO.
ECHO 1) User Name   ( %1 )
ECHO 2) Password    ( %2 )
ECHO 3) Server Name ( %3 )
ECHO 4) Database Name ( %4 )
GOTO Return
:RETURN


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>