I have the following simple query:
declare @product varchar(50);
select top 1 productid, count(*) as total from orderlines group by productid order by total desc
I need to get the productid from the query, store it in the variable @product and then use the variable in another query. How can i do that in MS SQL Server 2008?