我不知道为什么这个该死的剧本不起作用请帮助!!!
我只想使用我的日期参数获取信息。我得到的只是没有信息的列。
ALTER PROCEDURE [dbo].[sp_GerberCutter]
-- Add the parameters for the stored procedure here
@startdate Date,
@enddate Date,
@designid varchar (7)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT DISTINCT
SL.SALESID,
SL.DESIGNID,
DS.NAME as [DESIGN NAME],
CAST(ceiling(SL.MMI_WIDTHDIMENSION/12) as nvarchar(5)) + 'x' + CAST(ceiling(SL.MMI_LENGTHDIMENSION/12) as nvarchar(5)) AS SIZE,
SL.QTYORDERED as QTY,
DATEADD(ss,CCS.MMI_CONFIRMTIME, CCS.CONFIRMDATE) as ORDERCONFIRMED,
(SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.NOTES like '%CONVERT%PRODUCTION%') AS CUTFILE,
(SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%') AS CARPETCUT,
DATEDIFF(hour, (DATEADD(ss,CCS.MMI_CONFIRMTIME, CCS.CONFIRMDATE)), (SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%')) as HOURSTOCOMPLETE,
Case
When (SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%') Between DateAdd(hh, 07, @startdate) And DateAdd(hh, 14, DateAdd(mi, 59, @enddate)) Then 'S1'
When (SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%') Between DateAdd(hh, 15, @startdate) And DateAdd(hh, 22, DateAdd(mi, 59, @enddate)) Then 'S2'
When (SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%') Between DateAdd(hh, 23, @startdate) And DateAdd(hh, 30, DateAdd(mi, 59, @enddate)) Then 'S3'
End As [CARPETCUT SHIFT]
FROM DESIGNS.DBO.DesignLog DL
INNER JOIN AXLIVESALES.DBO.SALESLINE SL
ON SL.DESIGNID=DL.DESIGNNBR AND SL.RECID=DL.AxRecordId
INNER JOIN DESIGNS.DBO.DESIGNS DS
ON DL.DESIGNNBR=DS.NBR
INNER JOIN AXLIVESALES.DBO.CUSTCONFIRMSALESLINK CCS
ON CCS.SALESID=SL.SALESID AND CCS.DATAAREAID=SL.DATAAREAID
INNER JOIN INVENTDIM ID
ON SL.INVENTDIMID=ID.INVENTDIMID AND ID.DATAAREAID='V02'
WHERE
SL.DESIGNID = @designid and DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%' and SL.DATAAREAID='MMI'and (SELECT TOP 1 DL.Timestamp FROM DESIGNS.DBO.DesignLog DL WHERE DL.DESIGNNBR=SL.DESIGNID AND DL.DESIGNER='MTR' and DL.ACTION='P' and DL.NOTES like '%INLAID%') = @enddate
ORDER BY CARPETCUT DESC;
END
答案 0 :(得分:0)
在执行程序时,您是否确定将开始日期和结束日期传递给正确的参数?是否有一些地方混乱发生,月数被解释为天,反之亦然?