Back to blog

Stop viewing all databases in SSMS

December 12, 2014 - Posted in SQL Server Posted by:

I’ve got a setup on a server where I’ve got┬ámultiple users, each with┬átheir own database – a 1 to 1 mapping. By default, a login can see all databases in SQL Server Management Studio, even if they don’t have permissions to access them. Users are part of the public group so if you run the command:

USE MASTER
GO
DENY VIEW ANY DATABASE TO PUBLIC
GO

Then users will only be able to see the database(s) for which they are an owner. I’m putting it here because I always forget this command.