/ / Potrzebujesz pomocy w ustawieniu moich parametrów - sql-server, tsql, datetime, parametry

Potrzebujesz pomocy ustawić moje parametry - sql-server, tsql, datetime, parametry

Nie mam pojęcia, dlaczego ten przeklęty skrypt nie działa, proszę pomóż !!!

Chcę tylko uzyskać informacje za pomocą moich parametrów daty. Dostaję tylko kolumny bez wyciągniętych informacji.

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

Odpowiedzi:

0 dla odpowiedzi № 1

Czy jesteś absolutnie pewien, że masz datę początkową?i data zakończenia została przekazana do prawidłowych parametrów podczas wykonywania procedury? Czy jest możliwe, że pewne zamieszanie lokalnie ma miejsce, a liczby miesięcy są interpretowane jako dni i odwrotnie?