数据库设计报告与ppt 超市物流管理
查询销售记录的存储过程
CREATE PROCEDURE [dbo].search_sell_rec
@id varchar(8),
@name varchar(30),
@time varchar(30),
@mid varchar(8)
AS
IF (@mid = '')
BEGIN
SELECT P.p_id AS pid, P.p_name AS pname , P.p_scale AS pscale ,
S.s_qty AS sqty , S.s_price AS sprice , S.s_time AS stime ,
E.e_name AS ename FROM product P, sell S, employee E
WHERE P.p_id like '%'+@id+'%' and P.p_name like '%'+@name+'%'
and S.s_time like '%'+@time+'%' and S.p_id = P.p_id
and S.e_id = E.e_id
ORDER BY S.s_id desc
END
IF (@mid<>'')
BEGIN
SELECT P.p_id AS pid, P.p_name AS pname , P.p_scale AS pscale ,
S.s_qty AS sqty , S.s_price AS sprice , S.s_time AS stime ,
E.e_name AS ename , P.p_qty AS pqty FROM product P,
sell S, employee E
WHERE P.p_id like '%'+@id+'%' and P.p_name like '%'+@name+'%'
and S.s_time like '%'+@time+'%' and S.m_id =@mid and
S.p_id = P.p_id and S.e_id = E.e_id
ORDER BY S.s_id desc
END
GO
1