August 10, 2008 at 8:50 pm
Comments posted to this topic are about the item Remove SQL Logins from All Databases and SQL Server
Rudy
August 12, 2008 at 9:29 am
Hello. Please let me know what you think about this code, changes, etc.
Thanks,
Rudy
Rudy
April 29, 2011 at 12:50 pm
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 +']'
April 29, 2011 at 1:04 pm
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 +''''
Rudy
April 29, 2011 at 1:26 pm
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 ' '.
July 29, 2011 at 2:51 pm
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.
August 11, 2011 at 2:58 pm
February 21, 2012 at 7:40 pm
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
Change is inevitable... Change for the better is not.
June 3, 2012 at 10:48 am
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.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply