Adnan Ahmad
Adnan Ahmad

Reputation: 33

Is there any way to add a description at table level in SQL Server?

Suppose I have multiple tables in my database having almost similar name, so in that case, is it possible to add description at table level so, when i leave my current organization, it helps other developers to understand the use of table by it description. Just like we have it in Procedures

/*==============================================

Created By : Someone

Description : To Fetch Employee Details

Created Date : 2019-12-23 16:35:55.340

==============================================*/

Upvotes: 0

Views: 813

Answers (1)

Cedersved
Cedersved

Reputation: 1025

You can use extended properties for this, which is a feature in MS SQL Server that can be used for documentation purposes.

Here's example code on how to add a description for the Adress table in the Person schema in the AdventureWorks2012 database according to the MS documentation:

USE AdventureWorks2012;  
GO  
EXEC sys.sp_addextendedproperty   
@name = N'MS_DescriptionExample',   
@value = N'Street address information for customers, employees, and vendors.',   
@level0type = N'SCHEMA', @level0name = 'Person',  
@level1type = N'TABLE',  @level1name = 'Address';  
GO  

https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addextendedproperty-transact-sql?view=sql-server-ver15

Upvotes: 2

Related Questions