Try this out:
/*Set <Your DB Name> to the DB you want as default, and run it on each
production database on the new server, as well as 'master'*/
declare @user varchar( 50 ), @dbname varchar(10)
set @dbname = '<Your DB Name>'
declare get_db_users cursor for
select name
from sysusers
where name not like 'db_%'
and name not in ( 'guest', 'dbo', 'public' )
open get_db_users
fetch next from get_db_users into @user
while @@fetch_status = 0
begin
print @user + ' changed to ' + @dbname
exec sp_defaultdb @user, @dbname
fetch next from get_db_users into @user
end
close get_db_users
deallocate get_db_users
Bill Finch MCSE,CCNA
Database Administrator
LCG Technologies, Inc.
-----Original Message-----
From: Gord Debiasi
[mailto:mssqldba-ezmlmshield-x56690872.[Email address protected]
Sent: Thursday, September 27, 2007 4:45 PM
To: LazyDBA Discussion
Subject: Another quick one
During a server migration, all logins were transferred but the default
now is Master on each.
Is there a method by which to change the default databases of each login
to match their default on the original server.
Thanks Again.
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY To post a
dba job: http://jobs.lazydba.com To subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
This email, its electronic document attachments, and the contents
of its website linkages may contain confidential information. This
information is intended solely for use by the individual or entity
to whom it is addressed. If you have received this information in
error, please notify the sender immediately and arrange for the prompt
destruction of the material and any accompanying attachments.
MS Sql Server LazyDBA home page