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.
| 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]GODROP SCHEMA [User_0001]GOUSE [Database_Name]GODROP USER [User_0001]GOThanks |
|
|
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]GODROP SCHEMA [User_0001]GOUSE [Database_Name]GODROP USER [User_0001]GOThanks
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). |
 |
|
|
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]GODROP SCHEMA [User_0001]GOUSE [Database_Name]GODROP USER [User_0001]GOThanks
Please look at this thread.You will have better understanding.HTHhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=141065 |
 |
|
|
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? |
 |
|
|
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 |
 |
|
|
|
|
|