我的問題是,這個sproc中的最後一個查詢是說我需要聲明@N,但我已經有任何想法?爲什麼此查詢要求我在已有表格時聲明表格?
DECLARE @t TABLE
(Smpinstanceid UNIQUEIDENTIFIER)
INSERT INTO @t
(Smpinstanceid)
SELECT t.SmpInstanceid
FROM Tasks t
WHERE t.Completed IS NOT NULL and t.SmpInstanceID is not null
DECLARE @N TABLE
(SMPinstanceid UNIQUEIDENTIFIER,[Count] INT)
INSERT INTO @N
(SMPinstanceid,[COUNT])
SELECT Smpinstanceid,COUNT (Smpinstanceid) AS [Count]
FROM @t
GROUP BY Smpinstanceid
UPDATE Tasks
SET StepNum = @n.Count
WHERE Tasks.SmpInstanceID = @n.smpinstanceid
END
GO
第二個查詢爲我做了非常感謝。 – 2010-10-26 14:41:33