April 2, 2012 at 12:00 am
Hi All,
How to create a user defined database role to give create and alter permissions only on views.
Please advise.
Thanks and Regards,
Ravi.
April 2, 2012 at 1:43 am
create the role then grant CREATE VIEW to the role this will also imply ALTER as well
April 2, 2012 at 3:06 am
Thanks for your reply.
I have tried this but still not able to create view/alter view...throwing the below errors
Cannot alter the view 'v_xxxxx', because it does not exist or you do not have permission.
The specified schema name "dbo" either does not exist or you do not have permission to use it.
USE TestEcom
go
CREATE ROLE db_viewcreator
GO
GRANT CREATE VIEW TO db_viewcreator;
GO
EXEC sp_addrolemember N'db_viewcreator', N'testuser'
GO
Please check and advise.
Thanks and Regards,
Ravi.
April 2, 2012 at 4:21 am
you need to grant alter on the schema that you want the view to be created in to the role. if you have just given CREATE VIEW to the role then thats all they can do, they wont be able to create tables etc.
April 2, 2012 at 4:31 am
If I grant the alter, it will apply to all the objects but I need only for views.
GRANT ALTER TO db_viewcreator;
GO
Please advice me if I'm wrong.
Thanks and Regards,
Ravi.
April 2, 2012 at 4:34 am
GRANT ALTER ON SCHEMA::dbo TO db_viewcreator
This will say they have permission to alter the schema, but SQL needs to know what it can alter and as you have only given CREATE VIEW it can only alter and create views.
April 2, 2012 at 4:34 am
ravisamigo (4/2/2012)
Hi All,How to create a user defined database role to give create and alter permissions only on views.
Please advise.
Thanks and Regards,
Ravi.
Ravi take a look at this thread on the same theme of a role for view creation, and the proposed solution i put at the end:
http://www.sqlservercentral.com/Forums/Topic1241211-391-1.aspx
I thought the role needed a lot more than CREATE VIEWs because of the requirement to alter other views as well, so i went the route of giving db_DDLAdmin, and then a DDL trigger to limit it's usage to VIEWS only.
see if that is close to what you want.
Lowell
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply