Hi, I'm trying to add row numbers to a query so I can iterate through them easily in a loop. I have done it before in an Access query but now need to recreate this in a sql server stored procedure - this is the syntax I am using :
Alter Procedure spItemsToBillNum
As
SELECT (select count (*) from spItemsToBill as E2 where E2.jbID < E1.jbid)+1 AS itbrownum, *
FROM spItemsToBill AS e1
ORDER BY e1.jbID;
But this returns the error
Invalid object name spItemsToBill - this shouldn't be the case as it is definately an object.
Can anyone help on this one?
Thanks
Steph
Alter Procedure spItemsToBillNum
As
SELECT (select count (*) from spItemsToBill as E2 where E2.jbID < E1.jbid)+1 AS itbrownum, *
FROM spItemsToBill AS e1
ORDER BY e1.jbID;
But this returns the error
Invalid object name spItemsToBill - this shouldn't be the case as it is definately an object.
Can anyone help on this one?
Thanks
Steph