Link to home
Start Free TrialLog in
Avatar of Jamie Fellrath
Jamie FellrathFlag for United States of America

asked on

Trying to delete Login from SQL Server, getting error

Hi all,

I'm trying to delete a user from our MS SQL Server 2008 (yeah, I know) database server.  The user in question has left the organization and is no longer in Active Directory, but apparently his name is still all over the place.  

I've removed him from every database, and now I'm trying to delete him in SSMS in Object Explorer via <database name>/Security/Logins. It's giving me the following error:  

The server principal is set as the execution context of a trigger or event notification and cannot be dropped. (Microsoft SQL Server, Error: 15186)

I've removed him everywhere I could find him - jobs, etc.  Anyone have any other ways to find what setting he might be in, still? I've tried a  couple of queries from TechNet and such (example: https://social.technet.microsoft.com/Forums/en-US/3a337af8-cc60-4c66-a475-bd0965576545/the-database-principal-is-set-as-the-execution-context-of-one-or-more-procedures-?forum=sqlsecurity) but haven't found anything that helps yet.
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

I never liked to use the GUI to perform those kind of tasks.
Try to open a new query window and run the following command:
DROP LOGIN [Domain\login_name]

Open in new window

Avatar of Jamie Fellrath

ASKER

Thanks Vitor!

This doesn't seem to be working - apparently because the Login includes a backslash (due to its being an Active Directory login with domain specified).  The SQL doesn't care for the backslash.
Can you provide a print screen of the login in the SQL Server security / login folder?
Do you mean the "Properties" window?
Here's the screen print fragment of the login:  

User generated image

Is this what you mean? I'm sorry, but I'm not comfortable showing more than this login.
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, same error:  

Msg 15186, Level 16, State 1, Line 1
The server principal is set as the execution context of a trigger or event notification and cannot be dropped.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Check in the SQL Server instance / Server Objects / Triggers. It's some trigger created there?
Thanks Zberteoc. I've got him removed from all the databases already, including the system databases. I also checked the jobs... at least for him as the owner (and found a couple and changed the owner).  I'll check around more for the email notifications.

Vitor - I see a trigger there but don't see how to find the owner of it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I used our Redgate SQL Search tool to look for his name anywhere - and aside from notes made in old procedure code and the like, I'm not seeing anything. Assuming that the Triggers we're talking about are coded as owned in the EXECUTE AS clause, then I think we've exhausted that possibility.  

What about event notifications? Where might I look to find some of that stuff?
Look for the login name, specifically, but only for the btempleton part.

For notification look In the jobs. The jobs have Notification in case of failure and those can be tight with accounts. I am not 100% if are in connection with logins or just emails but you can check in the jobs' Properties and then in Alerts or Notification.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please give some feedback, award points if the answers were helpful or close this question if not.