HackRead

How to Hide Tables in SQL Server Management Studio


SQL Server Management Studio (SSMS) is a software application developed by Microsoft that is used for configuring, managing, and administering Microsoft SQL Server. It provides a user interface for connecting to SQL Server, managing databases, writing and executing queries, and performing various administrative tasks.

SSMS is a powerful tool for database developers, administrators, and analysts who need to work with SQL Server on a regular basis. It is widely used in organizations of all sizes and industries that rely on SQL Server for their data management needs.

With its rich set of features and intuitive user interface, SSMS has become an essential tool for anyone working with SQL Servers. There are moments when it is necessary to hide some tables in Object Explorer. Assume we have the Person.Address table, which we are going to hide:

To do this, we need to add an extended property to this table:

EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value="Hide",
@level0type = N'Schema', @level0name="Person",
@level1type = N'Table', @level1name="Address";
GO

Once done, the result is as follows:

How to Hide Tables in SQL Server Management Studio

To change things back, just delete the property.

EXEC sp_dropextendedproperty
@name = N'microsoft_database_tools_support',
@level0type = N'Schema', @level0name="Person",
@level1type = N'Table', @level1name="Address";
GO

I have tried to apply an extended property to columns and schemes. However, it did not work.

Advanced properties can hide tables from SSMS without access restriction.

DENY VIEW DEFINITION

VIEW DEFINITION is another way to hide tables in SSMS:

DENY VIEW DEFINITION ON Schema.Table TO UserName;

Now, a user cannot see a table in SSMS. Actually, they will not be able to get a list of tables from sys.tables or INFORMATION_SCHEMA.TABLES

Filtering

You can filter tables in any database:

How to Hide Tables in SQL Server Management Studio
How to Hide Tables in SQL Server Management Studio
How to Hide Tables in SQL Server Management Studio

It is necessary to do the following to remove a filter:

How to Hide Tables in SQL Server Management Studio

Comparison of approaches

VIEW DEFINITION is more flexible. You can limit the visibility of the whole schema or a separate table, a view, one user or a role. It also affects the system view, which is very good.

On the other hand, VIEW DEFINITION requires an explicit access lock. In my practice, there have been cases when someone locked access for some users and forgot to ban others, which caused challenges.

Extended properties with more severe restrictions are applied to everyone and do not require an explicit ban for each user. In addition, they affect sysadmins.

dbForge Studio for SQL Server

In addition to the methods described in the article, specialized tools exist for working with SQL Server databases. dbForge Studio for SQL Server is one such solution, as it offers several advantages to both developers and database managers.

dbForge Studio for SQL Server is a versatile SQL Server GUI client available for MacOS and Linux. Its cross-platform compatibility enables users of these operating systems to construct and maintain SQL Server databases without virtual machines or compatibility layers.

In conclusion, dbForge Studio for SQL Server is a robust and adaptable application that provides several benefits to SQL Server database users. Its user-friendly interface, excellent code completion and formatting capabilities, robust data editing and management tools, and cross-platform compatibility make it an asset to any database development or administration team.

  1. Magento 1 vs Magento 2
  2. Product Review – Stellar Repair for MS SQL
  3. How to repair suspect database in SQL Server
  4. How to Optimize Your Database Storage in MySQL
  5. How to Remove Duplicate Lines in EmEditor (2023)
  6. MySQL Performance Tuning: Tips for Blazing Fast Queries



Source link