How to make a user in SQL Server 2008 view only a VIEW?

Asked

Viewed 2,348 times

4

I made a View to send to a customer, but I can’t pass the login and password to the general access. This way I created a user (cliente_view) and I would like this to view only the created View (View_consult_vendas).

  • How to do this process above?
  • Gabriel, I found this question on Database Administrators. Ai says that you must grant access to this user. Maybe the question can be useful to you, if you can put the result to us in the answer :)

  • On your user, run the command that gives permission: GRANT SELECT ON dbo.MyViewName TO username;

  • You can create the user, assign no group, and give access only to view using the command: GRANT SELECT ON View_consulta_vendas TO cliente_view

  • Marconi, Everson and Ricardo. First thank you for your attention. USE SISTEMA_CLIENTE CREATE USER cliente_view for login cliente_view GRANT SELECT ON view_consulta_vendas_client TO cliente_view

2 answers

1

You need to give this user you created (cliente_view) the privilege you wish, in your case, to give access only for permission to SELECT, use the GRANT:

GRANT SELECT ON view_consulta_vendas TO cliente_view;

Note: as already created the user, check which permissions it already has, if you want to remove some, use the REVOKE.

  • Thank you very much Henrique, I will post what I did below to help other users!!

1

As help from the above staff, I was able to create the Login for the Database, create the user and associate to the login above and allow this user to view only that particular view with the following commands:

-- Criando Login para o SQL:
CREATE LOGIN cliente_view WITH PASSWORD = 'cliente123'
-- Comando para selecionar o sistema:
USE SISTEMA_CLIENTE
-- Criando o usuário e associando ao login criado no processo acima:
CREATE USER cliente_view for login cliente_view
-- Liberando permissão para visualização da View pro usuário criado:
GRANT SELECT ON view_consulta_vendas_cliente TO cliente_view

  • Good Gabriel! Glad I could help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.