My Issue is that the last query in this sproc is saying that I need to declare @N but I already have any ideas?
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