Working with Parameters
Let's get back to our procedure—there's a serious problem. It works great if we have only one customer who buys only one item, but what if that customer wants to buy something else? What if we have another customer? Should we write a separate procedure to handle each customer? Each product? Of course not. Instead we'll change the procedure to enable you to pass the customer ID, the order ID, and the product ID as parameters.
A parameter is a mechanism enabling a calling program to pass a value to a procedure so that the procedure can operate in response to that value.
An example of a parameter can be seen in the stored procedure sp_help that you have used in previous lessons. The table name in the statement shown ...
Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.