I’m looking to bulk remove users from a database with a script for every login with a name that matches a certain pattern. What is the best way to do this with TSQL?
DELETE syslogins WHERE.... does not work
Trying to delete straight from syslogins will return “Ad hoc updates to system catalogs are not allowed”
How about this query to create your TSQL statements? Then copy this SQL into a new query and exec.
This is basically the script that’ll be created and run when you delete/drop a login from SSMS.