Huh?
Try these. A RoleId is a uniqueidentifier
select top 1 * from dbo.aspnet_Roles IsAnonymous
--------------------------------------------------------------------------------------------------------------------------------
---------------------------------------- ---- ----------------------------------------
---- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---- ------------------ ---- ----------- ---- ----------------------------------------
----
select top 1 * from dbo.aspnet_Users
--------------------------------------------------------------- ----------------------------------------
---- ---------------------------------------- ----
select top 1 * from dbo.aspnet_UsersInRoles
--------------------------------------------------------------- ----------------------------------------
---- ---------------------------------------- ----
declare @RoleId uniqueidentifier
select @RoleId = (select top 1 RoleId from dbo.aspnet_Roles)
print @RoleID
select count(*) as ThisRoleCount from dbo.aspnet_UsersInRoles where RoleId =
@RoleId
declare @RoleName varchar(12)
select @RoleName = (select top 1 RoleName from dbo.aspnet_Roles)
print @RoleName
select count(*) as ThisRoleCount from dbo.aspnet_UsersInRoles link
join dbo.aspnet_Roles roles on link.RoleId = roles.RoleId
where RoleName = @RoleName
select users.UserId , users.UserName from dbo.aspnet_UsersInRoles link
join dbo.aspnet_Roles roles on link.RoleId = roles.RoleId
join dbo.aspnet_Users users on link.UserId = users.UserId
where RoleName = @RoleName
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:ey**************@TK2MSFTNGP02.phx.gbl...
Greetings,
I'm using ASP.NET membership and I'd like to query the number of users in
a particular role.
I don't want the overhead of returning a dataset and then getting the
number of items in it. I'd like to create a stored procedure for maximum
efficiency that returns the number of users in a particular role.
It appears that role IDs are encrypted in the membership tables so I'm not
really sure where to start. I was hoping this wouldn't be that complicated
as I'm pretty new to this.
Thanks for any tips.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com