Results 1 to 4 of 4

Thread: SQL 2005 system table Q

  1. #1
    Join Date
    May 2005
    Posts
    111

    SQL 2005 system table Q

    When I create a login it populates the syslogins table. What table stores the information from an sp_grantdbaccess? I need verify a user has access rights to a specific database before running a process? -A

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    In sys.sysusers of each db.

  3. #3
    Join Date
    May 2005
    Posts
    111
    THANK YOU !!! Now a follow-up question. Why do I receive an error when I uncomment the second EXEC--it works just fine as is however, I would like to run both SP's?

    BEGIN
    PRINT 'HELLO MOTO USER_ID: ' +@userID
    IF EXISTS (select name from sysusers where name = @userID)
    EXEC sp_addrolemember 'db_denydatareader', @userID
    --EXEC sp_addrolemember 'db_denydatawriter', @userID
    ELSE
    PRINT 'N/A'
    END

  4. #4
    Join Date
    Jan 2010
    Posts
    37
    I am not positive, but I think by default your if statement can only run a single statement. To run multiple statements, you will have to wrap the if statements in a begin/end statements.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •