Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / SQL / July 2008

Tip: Looking for answers? Try searching our database.

SMO: DefaultCollection for a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Walker - 24 Jul 2008 22:46 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.