July 7, 2010 at 1:07 pm
Hi ,
Does any one has script to Grant View Defination permission to any USER to all the views in a database ..
July 8, 2010 at 11:09 am
Using Google: "tsql script to grant permission"
The first result is:
I've made the edits for you down below. You just need to change "userid" to the person for whom you are granting permissions.
set nocount on
declare @object varchar(40)
declare mycursor scroll cursor
for
select name from sysobjects
where type = 'v'
order by name
open mycursor
fetch first from mycursor into @object
while @@fetch_status <> -1
begin
if @@fetch_status <> -2
begin
exec('GRANT VIEW DEFINITION on '+@object+' to [userid]')
end
fetch next from mycursor into @object
end
close mycursor
deallocate mycursor
set nocount off
July 15, 2010 at 11:14 pm
if you don't like to use cursors and while statement then this article is good
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply