1. 创建一个简单的存储过程,返回所有顾客的数量:
```sql
CREATE PROCEDURE GetCustomerCount
AS
BEGIN
SELECT COUNT(*) AS CustomerCount FROM Customers;
END
```
2. 创建一个存储过程,根据给定的国家参数返回该国家的所有顾客:
```sql
CREATE PROCEDURE GetCustomersByCountry
@Country NVARCHAR(50)
AS
BEGIN
SELECT * FROM Customers WHERE Country = @Country;
END
```
3. 创建一个存储过程,将给定的订单号参数作为输入,并返回该订单的详细信息:
```sql
CREATE PROCEDURE GetOrderDetails
@OrderID INT
AS
BEGIN
SELECT * FROM Orders WHERE OrderID = @OrderID;
END
```
4. 创建一个存储过程,将给定的产品类别参数作为输入,并返回该类别中所有产品的数量和平均价格:
```sql
CREATE PROCEDURE GetProductStats
@CategoryID INT
AS
BEGIN
SELECT COUNT(*) AS ProductCount, AVG(Price) AS AveragePrice
FROM Products
WHERE CategoryID = @CategoryID;
END
```