script for del users

  • Hi All,

    when iam deleting the login ,automatically user also deleted in GUI....

    So I want t-sql script for automatically delete the user when i delete the login belongs to that user..

    Thanks to all...

  • This script should work just fine:

    You may want to modify it a little so it first checks if the user exists:

    drop Login [login_name]

    go

    sp_msforeachDB 'Use [?]; DROP USER [user_name];'

    Ysaias Portes | Forward Thinkers Consulting
    sp_SQLFlightRecorder — open-source SQL Server diagnostic recorder | forwardthinkersconsulting.com

Viewing 2 posts - 1 through 2 (of 2 total)

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