Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Access

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-04-24 : 09:10:53
I want to create a profile with logins/users to have read access on a database views only.

Please help..

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-04-24 : 09:22:04
CREATE LOGIN [loginName] WITH PASSWORD=N'password'
GO

USE [databasename]
GO

CREATE USER [userName] FOR LOGIN [loginName] WITH DEFAULT_SCHEMA=[dbo]
GO

select 'grant select on ' + table_name + ' to [userName] ' from information_schema.tables where table_type = 'view'

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-04-24 : 09:33:35
Thanks..

May be i m not correct with my question.
We have users/logins already in server.


I would like to expose the views with read only access and nothing else. What is the best way to accomplish this?
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2012-04-24 : 11:33:05
Create a user defined role with securable as db_datareader and grant select on desired views for that role.Add the users to role to whom you wish to have read only access for the views.

After Monday and Tuesday even the calendar says W T F ....
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2012-04-24 : 13:09:20
quote:
Originally posted by sqlfresher2k7

I want to create a profile with logins/users to have read access on a database views only.

Please help..



Why do you keep cross posting now and then ?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=173937

After Monday and Tuesday even the calendar says W T F ....
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-04-24 : 18:11:03
Do i need to create the role specific to database or create in server security roles.I want to have the read access on databases views not specific to one database but multiple db views only.

Go to Top of Page
   

- Advertisement -