A
Andro Dgebuadze
Hi there
I am having a problem building Pivot Chart based on this particular Stored
Procedure, quoted below.
Any Idea why?
I am using Access 2002 and SQL Server 2000.
===========================================
CREATE PROCEDURE dbo.STOCK_INVENTORY_LEVELS
(@item as int)
AS
SET NOCOUNT ON
CREATE TABLE #t (DT datetime)
DECLARE @dt as datetime
DECLARE @dt1 as datetime
DECLARE @dt2 as datetime
SET @dt2 = CONVERT(datetime, ROUND(CONVERT(float, GETDATE()), 0, 1))
SET @dt1 = @dt2-60
SET @dt = @dt1
WHILE @dt <= @dt2
BEGIN
INSERT INTO #t VALUES ( @dt )
SET @dt = @dt + 1
END
SELECT ITEM_ID, #t.DT, CAST(SUM(QTY) AS DECIMAL(18,0)) AS QTY FROM Stocks AS
S (NOLOCK)
JOIN #t ON S.TRANS_DATE=(SELECT MAX(SS.TRANS_DATE) FROM Stocks AS SS(NOLOCK)
WHERE
SS.ITEM_ID = S.ITEM_ID AND
SS.AFE_ID = S.AFE_ID AND
SS.LOC_ID = S.LOC_ID AND
SS.COMPANY_ID = S.COMPANY_ID AND
SS.TRANS_DATE <= #t.DT )
WHERE ITEM_ID = @item AND LOC_ID <>1
GROUP BY ITEM_ID, #t.DT
DROP TABLE #t
GO
I am having a problem building Pivot Chart based on this particular Stored
Procedure, quoted below.
Any Idea why?
I am using Access 2002 and SQL Server 2000.
===========================================
CREATE PROCEDURE dbo.STOCK_INVENTORY_LEVELS
(@item as int)
AS
SET NOCOUNT ON
CREATE TABLE #t (DT datetime)
DECLARE @dt as datetime
DECLARE @dt1 as datetime
DECLARE @dt2 as datetime
SET @dt2 = CONVERT(datetime, ROUND(CONVERT(float, GETDATE()), 0, 1))
SET @dt1 = @dt2-60
SET @dt = @dt1
WHILE @dt <= @dt2
BEGIN
INSERT INTO #t VALUES ( @dt )
SET @dt = @dt + 1
END
SELECT ITEM_ID, #t.DT, CAST(SUM(QTY) AS DECIMAL(18,0)) AS QTY FROM Stocks AS
S (NOLOCK)
JOIN #t ON S.TRANS_DATE=(SELECT MAX(SS.TRANS_DATE) FROM Stocks AS SS(NOLOCK)
WHERE
SS.ITEM_ID = S.ITEM_ID AND
SS.AFE_ID = S.AFE_ID AND
SS.LOC_ID = S.LOC_ID AND
SS.COMPANY_ID = S.COMPANY_ID AND
SS.TRANS_DATE <= #t.DT )
WHERE ITEM_ID = @item AND LOC_ID <>1
GROUP BY ITEM_ID, #t.DT
DROP TABLE #t
GO