Tuesday, July 22, 2014

Hide all databases from users / login in SQL Server




Hide all databases from users / login in SQL Server

Steps

1. Create SQL login with some name kalyan_login, here dont specify any user mapping

2. From SSMS

USE master;

GO

DENY VIEW ANY DATABASE TO kalyan_login;

3. Granting database access to kalyan_login

USE master;

GO

ALTER AUTHORIZATION ON DATABASE::kalyandb TO kalyan_login;

GO

 

Now the login is able to view only one database that he has access

You can use the below command to hide databases from all logins

DENY VIEW ANY DATABASE TO PUBLIC;

No comments: