Can you please provide some more information on how you are trying to add and retrieve the Extended Properties using SMO. And also what version of SQL Server are you using.
Your code should look similar to -
Table t = mydb.Tables["tableName"];
foreach(ExtendedProperty exp in t.ExtendedProperties)
{
Console.WriteLine(exp.Name + " " + exp.Value);
}
t.ExtendedProperties.Add(new ExtendedProperty("propertyName", "property value"));
|||My code is pretty much just like that. I am using SQL Server 2005.|||Here is the code sample which I found working, let me know if you face any issues.
Server server = newServer("localhost");
Table table = server.Databases["mydatabase"].Tables["mytable"];
table.ExtendedProperties.Add(newExtendedProperty(table, "propertyName", "propertyValue"));
table.Alter();
table.Refresh();
foreach (ExtendedProperty e in table.ExtendedProperties)
{
Console.WriteLine(e.Name + " " + e.Value.ToString());
}
Thanks,
Kuntal
No comments:
Post a Comment