Using SMO in SQL Server 2005 and Visual Studio 2005: I would like to
get a collection of defaults that are defined for all tables in a
database.
I see the following data type:
Microsoft.SqlServer.Management.Smo.DefaultCollection
Is there an easy way to populate this? As a parallel, the
TableCollection can easily be populated from "SMODBConnection.Databases
(SourceDatabaseName).Tables", once the connection has been defined and
so on.
I can use this:
SMODBConnection.Databases(SourceDatabaseName).Tables(1).Columns
(1).DefaultConstraint
to get ONE default constraint, but I can't see how to get all of the
defaults for a database, or for a table, other than iterating over the
tables and the columns.
And, the existence of both a Default property and a DefaultConstraint
property of a table column, in the SMO object model, is confusing. In
SQL, defaults ARE constraints.
The VS 2005 and MSDN documentation is horrible: It doesn't show any
examples with code that shows the use of "DefaultCollection" datatype,
or the "DefaultConstraint" property, or the "Default" class or type.
Thanks for any help.
David Walker
David Walker - 24 Jul 2008 23:01 GMT
David Walker <none@none.com> wrote in news:Xns9AE5A087BF2B1DavidWalker@
207.46.248.16:
> Using SMO in SQL Server 2005 and Visual Studio 2005: I would like to
> get a collection of defaults that are defined for all tables in a
[quoted text clipped - 29 lines]
>
> David Walker
Nevermind, I found the Defaults property on the database. I swear it
wasn't there before. There must be a gremlin in my computer....
David Walker