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
 Old Forums
 CLOSED - General SQL Server
 Changing muliple users default db

Author  Topic 

hebegb
Starting Member

2 Posts

Posted - 2004-12-14 : 11:06:38
Greetings
In the process of moving a db from one server to another. I transfered logins using sp_help_revlogin.

Nowis I need to change the 324 users default db from master to the moved DB.

I cannot recall or find how to script all these users to there default db. I know it involves sp_defaultdb.
Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-12-14 : 11:38:27
This should get you started:

SELECT 'exec sp_defaultdb ''' + COALESCE(name,QUOTENAME(loginname)) + ''', ''newdb''', * FROM master..syslogins

That will generate the SQL needed to actually set the DB. Copy the results of that into a new query window, edit as needed, then run it.
Go to Top of Page

hebegb
Starting Member

2 Posts

Posted - 2004-12-14 : 12:05:57
Thanks that is exactly what I needed...
Go to Top of Page
   

- Advertisement -