SQL Server 2008. I need writing inline function that works with 2 parameters and returns a table. One of the parameter is amount of rows that should be return. But Transact SQL doesn't allow use @n inte select clause like: select top @n for example. How
can I choose fixing number of records (@n) inside the function?
View Complete Post
MSDN Magazine June 2000
Any ideas how I can order inside the subquery? I get the following error. I have tried ORDER BY MAX([Count]) but it doesn't like this much either... Also, I don't want to use TOP in the subquery as I need to use all the records!
COUNT(*) AS [Count]
GROUP BY System_User_ID
ORDER BY [Count]) l
INNER JOIN aspnet_Membership m
ON CAST(m.UserId AS VARCHAR(36)) = l.System_User_ID