Reputation: 45295
I need to select a field from the table and numerate it from some value. Something like this:
DECLARE @n AS INT
SET @n = 1111
SELECT F, @n = @n + 1 FROM MYTABLE
Is it possible?
Upvotes: 0
Views: 44
Reputation: 27377
You can't combine variable assignments with row selects. You might use ROW_NUMBER instead
Declare @n int= 1111
Select ID, @n + ROW_NUMBER() Over (Order by ID)
from aTable
Upvotes: 2