Database documentation within a database

Here are the sample scripts show how to write comment on each database object using SQL queries.

Adding comments to a table

-- Adding property to table
EXEC sys.sp_addextendedproperty   
	@name = N'MS_Description',	@value = N'Customer information.',   
	@level0type = N'SCHEMA',    @level0name = 'dbo',  
	@level1type = N'TABLE',     @level1name = 'tblCustomer';  
GO
 

Adding comment to column inside table

-- Adding to columns
 EXEC sp_addextendedproperty   
			@name		= N'MS_Description',@value = 'Identity column /Primary key column',  
			@level0type = N'Schema',		@level0name = 'dbo',  
			@level1type = N'Table',			@level1name = 'tblCustomer',   
			@level2type = N'Column',		@level2name = 'CustomerID';  
GO  

Other Refrence

Spread the love

1 thought on “Database documentation within a database”

  1. Pingback: Find all comments in SQL server for all kind of objects Himanshu Patel SQL Server Consultant developer & Administrator -

Comments are closed.