microsoft/mssql-scripter

Can I pass variable to external sql file?

manojsitapara2020 opened this issue · 0 comments

I have following external file in which I am using scripting variable, is it possible to pass these variable using mssql-scripter?

Insert into $(TODB).dbo.[OperationStateData] (myid, OperationName, TimeStamp, ExitCode, State) 
values
('$(variable1)', '$(OperationName)', GetDate(), $(ExitCode), '$(State)');

I am able to execute it in batch file like below, But I want to execute it using python

sqlcmd -E -S %HOST% -v TODB=%TODB% myid=%MY_ID% OperationName=%operationName% ExitCode=%ERRORLEVEL% State=%STATE_NAME% -i My_OperationState.sql > nul