I've already prevented user to see any database (deny view any database to [login]) and it works.
But how to prevent user to list any other database using
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
DB_NAME does not work as advertised before SQL Server 2016 (where the behaviour of
DB_ID is also changed). For details, see:
Information disclosure with the db_name and db_id function (Connect bug report)
There is a similar situation with other metadata functions, including:
These issues remain unresolved (either by design, or by being 'fixed') as of the time this answer was written, as far as I know.