Here’s how to execute a SQL Server Stored Procedure using SQLCMD. For demonstration purposes, I will be executing the ‘CustOrderHist’ Stored Procedure in the Northwind database. This procedure accepts the CustomerID and returns a list of orders placed by the Customer.
Open your Command Prompt. I have a named instance and use Windows Authentication, so I will be connecting to SQL Server using the following statement:
sqlcmd -S <ComputerName>\<InstanceName>
In my case, it is: sqlcmd -S SUPROTIM-PC\SUPROTIM2
Now enter the following commands:
:Setvar CustomerID ALFKI
EXEC dbo.CustOrderHist $(CustomerID)
The output is as shown below:
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|