create proc procname
@year int,
@month int
as
SELECT Categories.*
FROM Categories
WHERE (year = @year) AND (month = @month)
ORDER BY brandname

解决方案 »

  1.   

    以SQL Server的sale庫下的orders表為例子
    create proc test
    @order_id int,@customer_id int
    as
    select * from orders
    where order_id=@order_id and customer_id=@customer_idexec test @order_id=2,@customer_id=1
    結果:
    Order_id     Customer_id   sale_id   order_amount       order_date                                             2            1                 4        21332.5000            2001-03-12 00:00:00.000