• glad i could help a little Sapan;

    note that sp_msForEachDb is really is a cursor behind the scenes;

    while cursors are generally frowned upon, when fiddling with metadata, this is one of those acceptable scenarios i think.

    the other thing to note is that all the inner joins will automatically exclude orphaned users or users explicitly created WITHOUT LOGIN;

    i know i create those kinds of users for testing or permissions issues in various databases.

    create user [ClarkKent] without login;

    Execute As USER= 'ClarkKent'

    select user_name() --I'm Clark Kent!

    select * from sys.objects --nothing there! if he can see anything, it's because someone granted to PUBLIC!

    REVERT; --change back to superman

    drop user [ClarkKent]

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!