Store Procedure
-- Stored Procedure
create proc SelectAll
As
begin
select * from Production.Product
end
exec SelectAll
--------------------
create proc GetProductByCategoryName
@CategoryName nvarchar(225) -- Value
as
begin
select * from products
inner join categories on products.CategoryID=categories.CategoryID
where CategoryName=@CategoryName
end;
exec GetProductByCategoryName 'Condiments';
-----------------------------
create proc GetProductByCustomerId
@CustomerId int,
@CustomerCount int output
as
begin
select @CustomerCount=count(*) from orders
where CustomerID=@CustomerId
end;
declare @c1 int
exec GetProductByCustomerId 10,@c1 output
select @c1