How to get Orphan users information through mail

  • Hi All,

    Currently I have received one request from client and asking me to create a job and that needs to capture all orphan users in instance and needs to get mail with all the information.

    Please suggest me to proceed further

  • sp_change_users_login can be used to extract orphaned users.

    sp_send_dbmail can be used to send a report via email.

    Do you have specific issue with those stoed procedures? How can we help you? Show some code and we can suggest based on your issues.

    -- Gianluca Sartori

  • Through Below link we can able to pull all the orphan users in Instance level and I have get the mail with this information.

    http://www.sqlservercentral.com/blogs/rocks/2011/10/20/finding-orphaned-database-users/

  • New persopn (3/8/2016)


    Through Below link we can able to pull all the orphan users in Instance level and I have get the mail with this information.

    http://www.sqlservercentral.com/blogs/rocks/2011/10/20/finding-orphaned-database-users/%5B/quote%5D

    I haven't tested it, but looking at that query makes me wonder if Gianluca's sp_change_users_login would be faster. It would certainly be simpler. Either way you go, the the sp_send_dbmail suggestion is the way to go.

  • Re: sp_change_users_login, from the Books Online article:

    This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER USER instead.

    Here is another way to accomplish the same across all databases:

    Loginless In Seattle[/url]

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Orlando Colamatteo (3/8/2016)


    Re: sp_change_users_login, from the Books Online article:

    This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER USER instead.

    Here is another way to accomplish the same across all databases:

    Loginless In Seattle[/url]

    I remember when Andreas Wolter first told me about that procedure and I asked him about that very same note. He said that there's nothing to really replace it and he didn't expect it to go away any time soon. I'm thinking that if it is actually removed, I'll try to create a local version of it from the source.

  • Ed Wagner (3/8/2016)


    Orlando Colamatteo (3/8/2016)


    Re: sp_change_users_login, from the Books Online article:

    This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER USER instead.

    Here is another way to accomplish the same across all databases:

    Loginless In Seattle[/url]

    I remember when Andreas Wolter first told me about that procedure and I asked him about that very same note. He said that there's nothing to really replace it and he didn't expect it to go away any time soon. I'm thinking that if it is actually removed, I'll try to create a local version of it from the source.

    I did something similar using the code in the article I linked to.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Orlando Colamatteo (3/8/2016)


    Ed Wagner (3/8/2016)


    Orlando Colamatteo (3/8/2016)


    Re: sp_change_users_login, from the Books Online article:

    This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER USER instead.

    Here is another way to accomplish the same across all databases:

    Loginless In Seattle[/url]

    I remember when Andreas Wolter first told me about that procedure and I asked him about that very same note. He said that there's nothing to really replace it and he didn't expect it to go away any time soon. I'm thinking that if it is actually removed, I'll try to create a local version of it from the source.

    I did something similar using the code in the article I linked to.

    I must admit that I didn't check it out the first time. Now I see it's an article you wrote, so I'll have to read it. Thanks.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply