Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server 2008 script to drop all users.

Author  Topic 

crackerbox
Starting Member

21 Posts

Posted - 2010-03-09 : 17:08:21
I was sent the script below to drop users as part of an upgrade to SQL 2008. There are over 1000 users and I would like a script to drop them all at one time. Does anyone have any suggestions how to change the script to do that?: I would need to drop user_0001 to user_1000.


USE [Database_Name]
GO
DROP SCHEMA [User_0001]
GO
USE [Database_Name]
GO
DROP USER [User_0001]
GO

Thanks

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-03-09 : 23:42:00
quote:
Originally posted by crackerbox

I was sent the script below to drop users as part of an upgrade to SQL 2008. There are over 1000 users and I would like a script to drop them all at one time. Does anyone have any suggestions how to change the script to do that?: I would need to drop user_0001 to user_1000.


USE [Database_Name]
GO
DROP SCHEMA [User_0001]
GO
USE [Database_Name]
GO
DROP USER [User_0001]
GO

Thanks



Please try this approach..
SELECT col1, col2, ... INTO #Holdingtable FROM MyTable WHERE usersid required
TRUNCATE TABLE MyTable
INSERT MyTable (col1, col2, ...) SELECT col1, col2, ... FROM #Holdingtable

Note:<b>Truncating the tbl</b> :resetting any auto-incrementing primary keys to their start value (0).
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-03-10 : 00:05:04
quote:
Originally posted by crackerbox

I was sent the script below to drop users as part of an upgrade to SQL 2008. There are over 1000 users and I would like a script to drop them all at one time. Does anyone have any suggestions how to change the script to do that?: I would need to drop user_0001 to user_1000.


USE [Database_Name]
GO
DROP SCHEMA [User_0001]
GO
USE [Database_Name]
GO
DROP USER [User_0001]
GO

Thanks



Please look at this thread.You will have better understanding.HTH
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=141065
Go to Top of Page

crackerbox
Starting Member

21 Posts

Posted - 2010-03-10 : 08:18:54
These are user objects not items in a table. Will this script work the same way?
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-03-10 : 09:14:20
quote:
Originally posted by crackerbox

These are user objects not items in a table. Will this script work the same way?



Not sure..Let's wait for a while experts will give you the better suggestion..make sure please you explained your screanario in a such way that understoods well which would make them advice you well.
okay.Though I'am a beginner of sql..Thanks
Go to Top of Page
   

- Advertisement -