I'm doing a simple select query from a SQL database using a stored procedure.
SELECT TOP 100 ID, FirstName, LastName, MailedDate
FROM dbo.Table
ORDER BY MailedDate
What I can't figure out how to do is include the row number as a field in the stored procedure.
I did some searching and saw how to use @@ROWCOUNT but that didn't work. It returns the same value (in my case 100) for each row. I wanted it to increment like the first row would have 1 as a value, second row would have 2, etc.
Any insight on this is appreciated.
SELECT TOP 100 ID, FirstName, LastName, MailedDate
FROM dbo.Table
ORDER BY MailedDate
What I can't figure out how to do is include the row number as a field in the stored procedure.
I did some searching and saw how to use @@ROWCOUNT but that didn't work. It returns the same value (in my case 100) for each row. I wanted it to increment like the first row would have 1 as a value, second row would have 2, etc.
Any insight on this is appreciated.