Reputation: 47
Is it possible to hide (and show) some tables in object explorer of SQL Server 2014? Actually there are repetitive log tables which are prefixed with actual table. I want to hide them temporarily. Also when needed I want to show them back.
Upvotes: 1
Views: 897
Reputation: 28900
you can use extended properties
EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value = 'Hide',
@level0type = N'Schema', @level0name = 'Person',
@level1type = N'Table', @level1name = 'Address';
GO
Above code hides person.address table
If you want to revert,below is the code
EXEC sp_dropextendedproperty
@name = N'microsoft_database_tools_support',
@level0type = N'Schema', @level0name = 'Person',
@level1type = N'Table', @level1name = 'Address';
GO
References: Hiding tables in SSMS Object Explorer
You also can use below to deny viewing any user particular schema or table in object explorer,but this doesn't work when user is of higher role like db_owner..
DENY VIEW DEFINITION ON Schema.Table TO UserName;
Upvotes: 2
Reputation: 7161
try this one
if you want to hide table
use this one
EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value = 'Hide',
@level0type = N'Schema', @level0name = 'Person',
@level1type = N'Table', @level1name = 'Address';
GO
and show table
use this one
EXEC sp_dropextendedproperty
@name = N'microsoft_database_tools_support',
@level0type = N'Schema', @level0name = 'Person',
@level1type = N'Table', @level1name = 'Address';
GO
Upvotes: 1
Reputation: 136
You can add an extended property which will hide the table:
EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value = 'Hide',
@level0type = N'Schema', @level0name = '**YOUR SCHEMA**',
@level1type = N'Table', @level1name = '**YOUR TABLE NAME**';
GO
Upvotes: 0