ALTER PROCEDURE [dbo].[K_FS_GetDynamicdatatoTable] --'2014031711','1/15/2014 12:00:00 AM'
@orderno varchar(50),
@date datetime
AS
BEGIN
SET NOCOUNT ON;
SELECT
FT.feedtype, BG.bagtype, OD1.noofbags, round(MR.rateperkg, 3) AS rateperkg
FROM
K_FS_OrderDetails OD
INNER JOIN
K_FS_OrderDetails1 OD1 ON OD.sno = OD1.ID
INNER JOIN
K_FS_bagtype BG ON BG.sno = OD1.bagtype
INNER JOIN
K_FS_FeedMrpDetails MR ON MR.feedtype = OD1.feedtype
INNER JOIN
k_FPS_FeedType FT ON FT.sno = MR.feedtype AND FT.sno = OD1.feedtype
WHERE
OD.orderno = @orderno AND MR.date = @date
END
在我的程序中,没有条件执行成功,如果我通过OD.Orderno然后没有问题..但如果我提到MR.date然后没有找到数据...在这我错了吗?
这里
select * from K_FS_FeedMrpDetails where date = '2013-12-16 00:00:000'
'date'数据也可以在我的程序中使用,但找不到数据...请帮助我?
答案 0 :(得分:1)
试试这个
ALTER PROCEDURE [dbo].[K_FS_GetDynamicdatatoTable] --'2014031711','1/15/2014 12:00:00 AM'
@orderno varchar(50),
@date datetime
AS
BEGIN
SET NOCOUNT ON;
select FT.feedtype,BG.bagtype,OD1.noofbags,round(MR.rateperkg,3)as rateperkg
from K_FS_OrderDetails OD
Left join K_FS_OrderDetails1 OD1 on OD.sno=OD1.ID
Left join K_FS_bagtype BG on BG.sno=OD1.bagtype
Left join K_FS_FeedMrpDetails MR on MR.feedtype=OD1.feedtype
Left join k_FPS_FeedType FT on FT.sno=MR.feedtype and FT.sno=OD1.feedtype
where OD.orderno=@orderno and CONVERT(VARCHAR(10),MR.date,110)= CONVERT(VARCHAR(10),@date,110)
END