SQL Server 2008
Thanks! We'll email you
when relevant content is
added and updated.
How can I make it so that I can store the top 2 results in 2 variables?
create table t(id int);
insert into t (id) values (1),(2),(3),(4);
declare @id1 int
declare @id2 int
select top 2 @id1 = first id, @id2 = next id
Is there a way to make this happen in one query without using a loop?