Getting column description and Update descriptions in SQL Server

We are working on code generation and  update thought it would be neat to pull information from description  The following query did that trick.

SELECT [Table Name] = i_s.TABLE_NAME,
[Column Name] = i_s.COLUMN_NAME,
[Description] = s.value
FROM INFORMATION_SCHEMA.COLUMNS i_s
LEFT OUTER JOIN sys.extended_properties s
ON s.major_id = OBJECT_ID(i_s.TABLE_SCHEMA+'.'+i_s.TABLE_NAME) AND s.minor_id = i_s.ORDINAL_POSITION AND s.name = 'MS_Description'
WHERE OBJECTPROPERTY(OBJECT_ID(i_s.TABLE_SCHEMA+'.'+i_s.TABLE_NAME), 'IsMsShipped')=0 AND i_s.TABLE_NAME = 'Emp'
ORDER BY i_s.TABLE_NAME, i_s.ORDINAL_POSITION




UPDATE DESCRIPTION:
EXEC sp_updateextendedproperty
@name = N'MS_Description'
,@value = 'Emp Number must be Unique'
,@level0type = N'Schema', @level0name = dbo
,@level1type = N'Table',  @level1name = emp
,@level2type = N'Column', @level2name = empno;





ADD NEW COLUMN DESCRIPTION:

EXEC sp_addextendedproperty
@name = N'MS_Description'
,@value = 'Employee Name'
,@level0type = N'Schema', @level0name = dbo
,@level1type = N'Table',  @level1name = emp
,@level2type = N'Column', @level2name = ename;



Your Location