January 4, 2011 at 2:12 pm
How to make tables in a schema as views with readonly permission.
Any help is appreciated
January 4, 2011 at 2:18 pm
do you mean you want to create a role so that when users connect, the tables are read only?
USE Whatever
CREATE ROLE [ReallyReadOnly]
--give reader writes to this group
ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [ReallyReadOnly]
--explicitly DENY access to writing
ALTER AUTHORIZATION ON SCHEMA::[DB_DenyDataWriter] TO [ReallyReadOnly]
IF NOT EXISTS (SELECT * FROM MASTER.dbo.syslogins WHERE name = N'bob')
BEGIN
EXEC MASTER.dbo.sp_addlogin @loginame = N'bob', @passwd = 'NotARealPassword', @defdb = N'WHATEVER', @deflanguage = N'us_english'
--add this user to permit read only group
END
CREATE USER [bob] FOR LOGIN [bob]
EXEC sp_addrolemember ReallyReadOnly, N'bob'
or do you want to actually create 1000 new views that each point to an actual table (whether the same db or a different one)?
Lowell
January 4, 2011 at 2:22 pm
Thanks for your quick reply
I want to create all those tables as views & give readonly permission.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply