-- Put your restored database name here...
USE [RestoredDB];
GO
EXECUTE sp_configure 'allow' , 1;
RECONFIGURE WITH OVERRIDE;
go 
/*
        Delete all NT / SQL Server users that have access to the 
        database and if they do not have a valid login on the server.
*/
DELETE sysusers 
WHERE SUSER_SNAME( sid ) IS NULL And           -- Invalid logins on the server
      1 IN ( IsNTUser , ISSQLUser ) And        -- Check for NT / SQL users
      sid is not null And HasDBAccess = 1      -- Valid accounts in the table
go 
EXECUTE sp_configure 'allow' , 0;
RECONFIGURE WITH OVERRIDE 
GO 
This page was last updated on May 01, 2006 04:28 PM.