Results 1 to 2 of 2

Thread: can't drop user

  1. #1
    Join Date
    Jul 2009
    Posts
    6

    can't drop user

    Hi
    I am using SQL server 2005.
    I had created a login 'test12' in my database a long time back and also created a user with same name in 'infotech' database.

    Now there was some requirement that i had to drop the login 'test12' so the user 'test12' became an orphaned user in my database 'infotech'

    when i try to drop the user 'test12' i am getting an error as below:

    Msg 15136, Level 16, State 1, Line 1
    The database principal is set as the execution context of one or more procedures, functions, or event notifications and cannot be dropped.

    I know i had created many functions using 'test12' in EXECUTE AS clause of my functions. so in order to drop the user i need to alter the functions in order to remove the user test12 from EXECUTE AS CLAUSE i guess.

    But the thing is i have approx 200 functions from which i need to search where i had used test12 user. That is quite hectic obviously.

    so is there any alternative so that i dont have to search all 200 functions???

    or is there any other way to drop the user??

    Thanks !!!

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    You can query syscomments to find object names that reference user test12.

Posting Permissions

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