Reputation: 3447
I have a simple SQL statement that is to get the first rowid from question, but it gives an error thanks to too many items return. So how can I fix it ?
DECLARE @first_id int
select @first_id = (SELECT row_number() over (order by id) as id FROM question)
SELECT @first_id = id FROM question
>> this syntax works fine but not what I want from query result.
Thanks
Upvotes: 0
Views: 2304
Reputation:
Do you need the ROW_NUMBER or just the id field itself? If it is the id field it is simple:
SELECT @first_id = MIN(id) FROM question
Upvotes: 3