I need to call a stored procedure and pass arguments in from Powershell. I think the best option is to use sqlcmd.exe but I’m not sure how to pass arguments to the stored proc using this tool.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
sqlcmd.exe supports variable substitution and parameters via the
/vargument, see Using sqlcmd with Scripting Variables. For example:will invoke the procedure passing the value 1 to the script to be substituted for the variable
$(myparam). Note that sqlcmd variable substitution is a string replacement of$(variable)which occurs in sqlcmd, befor the batch (request) is sent to the SQL Server.