Crea utente per tutti i db, facendo anche il mapping utente.
set nocount on
declare #cur cursor for
select name
from sys.databases
where database_id > 4
order by name
open #cur
declare @db as nvarchar(100)
fetch next from #cur into @db
declare @sq as nvarchar(max)
while @@fetch_status = 0
begin
set @sq = N'
USE [' + @db + ']
--CREATE USER [user.name] FOR LOGIN [user.name]
--EXEC sp_addrolemember N''db_owner'', N''user.name''
--DROP USER [user.name]
'
print @sq
exec sp_executesql @sq
fetch next from #cur into @db
end
close #cur
deallocate #cur