by Hari Mukkapati
26. June 2009 04:22
set nocount on
declare @object varchar(40)
declare mycursor scroll cursor
for
select name from sysobjects
where type = 'u'
order by name
open mycursor
fetch first from mycursor into @object
while @@fetch_status <> -1
begin
if @@fetch_status <> -2
begin
exec('grant SELECT, INSERT, UPDATE, DELETE on '+@object+' to [userid]')
end
fetch next from mycursor into @object
end
close mycursor
deallocate mycursor
set nocount off
Recently I was working on a database and Had to GRANT Select, Update, Delete, Insert permissions to one user on all tables in one data base. So, Below script will do the job.