I'm creating a database with a few different schemas.
99% of users connect using Excel, and when they do they see all the system stuff:
This just confuses the users and I would like to configure SQL Server so that they only see UK_data and UK_reports.
So far I tried denying select on the things that I want to hide and only allowing select on the UK_ schemas, but it didn't work.
Is there a way to hide them from users?
Thanks!
-
Does this answer your question? How To Hide Schema from useruser212533– user2125332021年03月08日 14:33:29 +00:00Commented Mar 8, 2021 at 14:33
-
@bbaird Thanks for your suggestion but no. That approach let's me hide the data but not the schema. I want to hide the schemas and system things to avoid confusing the users..None– None2021年03月08日 14:45:58 +00:00Commented Mar 8, 2021 at 14:45
-
@Nacho so you just want to show a limited number of tables?Francesco Mantovani– Francesco Mantovani2021年03月08日 20:45:38 +00:00Commented Mar 8, 2021 at 20:45
-
@FrancescoMantovani something like that. I have a schema that has the tables with all the data. I created other schemas that only contain views to those tables. I want to limit which users can see which schemas, and therefore which views.None– None2021年03月09日 08:56:31 +00:00Commented Mar 9, 2021 at 8:56
-
That is even better @Nacho. So users can only have access to views. Through Excel?Francesco Mantovani– Francesco Mantovani2021年03月09日 13:11:34 +00:00Commented Mar 9, 2021 at 13:11
1 Answer 1
I maybe found two solution for you:
- HIDE
Hide Table "Person.Address"
EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value = 'Hide',
@level0type = N'Schema', @level0name = 'Person',
@level1type = N'Table', @level1name = 'Address';
GO
Show Table "Person.Address"
EXEC sp_dropextendedproperty
@name = N'microsoft_database_tools_support',
@level0type = N'Schema', @level0name = 'Person',
@level1type = N'Table', @level1name = 'Address';
GO
- DENY
`DENY VIEW DEFINITION ON Schema.Table TO UserName;`
Now UserName won’t be abe to see Table in Object Explorer. In Fact, they won’t be able to see the table in sys.tables or INFORMATION_SCHEMA.TABLES.
You can Use the DENY
keyword to deny certain Users and REVOKE
to Remove the existing permission.
Explore related questions
See similar questions with these tags.