Server::GetDefaultInitFields Method (Type^)

 

Returns the property types that are initialized by default when the specified object is initialized.

Namespace:   Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public:
StringCollection^ GetDefaultInitFields(
	Type^ typeObject
)

Parameters

typeObject
Type: System::Type^

A Type system object that specifies the type of object.

Return Value

Type: System.Collections.Specialized::StringCollection^

A StringCollection system object that contains a list of property types that are initialized by default when the specified object is initialized.

This method is used to control the way in which object properties are initialized in an SMO application. You can use this method to optimize your SMO application.

Visual Basic

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")
$tb = new-object Microsoft.SqlServer.Management.Smo.Table
$typ = $tb.GetType()
$sc = $srv.GetDefaultInitFields($typ)
$srv.SetDefaultInitFields($typ, "CreateDate")
foreach ($tb in $db.Tables)
{
   Write-Host $tb.Schema,".",$tb.Name,".",$tb.CreateDate
}
$srv.SetDefaultInitFields($typ, $sc)
Return to top
Show: