0

如何创建一个程序并且WHERE列是相同的?

WHERE列是QuotationNo

这是程序签名:

create procedure (QUO1 int, QUO2 int, QUO3 int, QUO4 int)

输出:

Quote     price     quantity
---------------------------------
1234       2000        1000
5678       2500        4000
9012        3000        4500 
3456        1000        1000

谢谢,

船长16

4

2 回答 2

1
CREATE PROCEDURE NameMyProc
    @QUO1 int, @QUO2 int, @QUO3 int, @QUO4 int
AS
    select quote, price, quantity
     from tbl
    where quotationno in (@qu01, @qu02, @qu03, @qu04)
GO

您还可以创建一个更灵活的表值函数,例如

CREATE FUNCTION dbo.NameMyFunction (
    @QUO1 int, @QUO2 int, @QUO3 int, @QUO4 int
) RETURNS TABLE AS RETURN
    select quote, price, quantity
     from tbl
    where quotationno in (@qu01, @qu02, @qu03, @qu04)
GO

-- Example usage:
SELECT * FROM dbo.NameMyFunction(1234, 5678, 9012, 3456) T
于 2012-11-05T09:33:15.080 回答
0

如果您在运行时给予 quo 价值

create proc [test]
 (QUO int(11))
as 
begin
select quote,price,quantity from table where quote=@QUO 
end
于 2012-11-05T09:35:04.720 回答