sp_change_users_login for all databases

Last Post 17 May 2007 02:53 AM by sqladmin. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
sqladmin
New Member
New Member

--
17 May 2007 02:53 AM
here is a script which will produce the sp_change_users_login code
for all databases.

remember to change the output to 'text' or press CTRL+T
--------------------------------------

use master
go
set nocount on
select 'use ' + name +char(10) + 'go ' + char(10) + 'print ''Database: ' + name + ''''
+ char(10)+ 'go ' + char(10) + 'select ''sp_change_users_login ''''update_one'''', '''' + name + '''','''' + name + '''' + char(10) + ''''go'''' from sysusers where name not like ''''db_%'''' and name not like ''''public'''' and name not like ''''guest''''
+ char(10) + ''''go''''' from sysdatabases

---------------------------------------

just take the output and run it.

You are not authorized to post a reply.

Acceptable Use Policy