rianto isaac's Weblog

rianto utomo isaac sahala utomo

sql7, user di semua database

leave a comment »

/*
— hapus dulu usernya
exec sp_droplogin zz
— buat user lagi
exec sp_addsrvrolemember zz, sysadmin
*/

–exec sp_addsrvrolemember N’zz’, sysadmin

declare @db varchar(50), @sql nvarchar (1000)

declare dbx cursor for
select name from sysdatabases
open dbx
fetch from dbx into @db
while @@fetch_status = 0
begin
— add user sebagai dbo
–exec sp_addrolemember N’db_owner’, N’zz’
set @sql = N’use ‘ + @db + ‘ exec sp_revokedbaccess zz’
set @sql = N’use ‘ + @db + ‘ exec sp_grantdbaccess zz’
set @sql = N’use ‘ + @db + ‘ exec sp_addrolemember db_owner, zz’

–print @sql
exec (@sql)

fetch next from dbx into @db
end
close dbx
deallocate dbx

Written by isaaconi

Juni 28, 2011 pada 10:35 am

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: