Question : IS_MEMBER Always returns roles for user dbo

SQL Server 2000.

  Does anyone know the reason why IS_MEMBER would return roles for the dbo user and not the current user?  Below is a SP which is supposed to get the roles for the current user.  However it always returns the roles for the dbo user.

Any thoughts?

Jim.

CREATE PROCEDURE trvsp_CurrentGroup
@GroupID varchar(1000) OUT
AS

declare @grp varchar(40)
SELECT @GroupID = ''
DECLARE cur_Group CURSOR FOR
SELECT name From sysusers WHERE uid = gid order by name
FOR READ ONLY
OPEN cur_Group
FETCH NEXT FROM cur_Group INTO @grp
WHILE (@@FETCH_STATUS <> -1)
BEGIN
 IF (@@FETCH_STATUS <> -2)
 BEGIN
  IF IS_MEMBER(@grp) = 1
  BEGIN
   IF (@GroupID = '')
    SELECT @GroupID = '''' + @grp + ''''
   ELSE
    SELECT @GroupID = @GroupID + ',''' + @grp + ''''
  END
 END
 FETCH NEXT FROM cur_Group INTO @grp
END
CLOSE cur_Group
DEALLOCATE cur_Group
GO

Answer : IS_MEMBER Always returns roles for user dbo

Another suggestion:

select u.name, r.name
from sysmembers m
join sysusers r
on r.uid = m.groupuid
and r.uid = r.gid
join sysusers u
on u.uid = memberuid
where u.uid =user_id()

does this query return good results?
Random Solutions  
 
programming4us programming4us