|
|
|
Old Hand
      
Group: General Forum Members
Last Login: 2 days ago @ 7:38 AM
Points: 306,
Visits: 1,012
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: 2 days ago @ 7:38 AM
Points: 306,
Visits: 1,012
|
|
Hello. Please let me know what you think about this code, changes, etc.
Thanks,
Rudy
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, April 29, 2011 1:13 PM
Points: 2,
Visits: 1
|
|
Rudy,
First thanks for posting the sp. The code it generates uses sp_dropuser and that does not work for usernames that contain periods. One of the applications we use creates usernames in the following format: vdb_First.Last
EXEC sp_droplogin vdb_First.Last results in:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '.'.
Looks like you need to enclose your output like you did with the sp_dropuser:
PRINT 'EXEC sp_droplogin ['+ @SpecificName +']'
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: 2 days ago @ 7:38 AM
Points: 306,
Visits: 1,012
|
|
Hello Ryan,
Thanks for the update. Guess I didn't think of this when I wrote the script as I have not seen anyone using the "." in the login name.
Thanks,
Rudy
ryan.hobbs (4/29/2011)
Rudy, First thanks for posting the sp. The code it generates uses sp_dropuser and that does not work for usernames that contain periods. One of the applications we use creates usernames in the following format: vdb_First.Last EXEC sp_droplogin vdb_First.Last results in: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '.'. Looks like you need to enclose your output with single quotes: PRINT 'EXEC sp_dropuser ''['+ @DatabaseUser +']''' and PRINT 'EXEC sp_droplogin '''+ @SpecificName +''''
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, April 29, 2011 1:13 PM
Points: 2,
Visits: 1
|
|
No worries.
FYI: I just edited my original post as the sp_dropuser is okay. It is just the sp_droplogin that needs to be enclosed. Looks like [ ] works as good as ' '.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, February 05, 2013 12:47 PM
Points: 15,
Visits: 194
|
|
| Nice script. I had to add SID matching for my purposes. It's possible that the name in sysusers is different from the login that it points to in syslogins.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: 2 days ago @ 4:05 PM
Points: 412,
Visits: 857
|
|
This script generates the script to drop users only for the users who don't own a schema.
It would have been better if it can generate like that too. I'll try to edit this script.. and post here
--SQLFRNDZ
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 12:30 PM
Points: 32,893,
Visits: 26,770
|
|
Thanks for sharing your knowledge. I haven't tried it but it looks like the code won't actually work if the user owns something like a schema, etc.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Sunday, May 12, 2013 3:18 AM
Points: 3,
Visits: 99
|
|
| DROP LOGIN [domainName\userName] is good for both SQL and Windows users, and deletes also related users, for me this simple syntax more usable than your SP.
|
|
|
|