How can I get and set the description property of a SQL Server 2008 table using SMO?

advertisements

How can I get and set the description property of a SQL Server 2008 table using Microsoft.SqlServer.Management.Smo? I have seen documentation on how to do this at the column level but not at the table level.


I was able to do the following in powershell:

$s = new-object microsoft.sqlserver.management.smo.server '.';
$db = $s.Databases['AdventureWorks2012'];
$t = $db.Tables | where {$_.Name -eq 'Address'};
$t.ExtendedProperties['MS_Description']; # will print current value
$t.ExtendedProperties['MS_Description'].Value = 'new value';
$t.ExtendedProperties['MS_Description'].Alter(); #persist the new value to the database