Search code examples
batch-filestored-proceduressqlcmd

Run stored procedure passing a parameter from Batch file


I have the below in a batch file and can not seem to get the %1 value to pass to the stored procedure. I have tried many combinations and searches without success. Can someone tell me how to format the command to pass that value to the stored procedure. I know the value is making it there because of the echo. The value is like such 0055731. thanks for any help.

echo %1
pause   
sqlcmd -S Esserver\rsssql -d RSSIntegration -Q "exec sp_ImportSageOrders " & %1

Solution

  • I have this working by including the %1 parameters inside the double quotes and if more than one parameter then put a , between each.

    Example as follows:

    echo %1 %2
    pause
    sqlcmd -S Esserver\rsssql -d RSSIntegration -Q "exec sp_ImportSageOrders %1, %2"