Export (0) Print
Expand All

DataType Constructor (XmlSchemaCollection)

Initializes a new instance of the DataType class based on a specified XML schema collection.

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

public DataType(
	XmlSchemaCollection xmlSchemaCollection
)

Parameters

xmlSchemaCollection
Type: Microsoft.SqlServer.Management.Smo.XmlSchemaCollection
A XmlSchemaCollection object variable that specifies an XML schema collection.

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server()
'Reference the AdventureWorks2012 database.
Dim db As Database
db = srv.Databases("AdventureWorks2012")
'Define an XmlSchemaCollection object by supplying the parent database and name arguments in the constructor.
Dim xsc As XmlSchemaCollection
xsc = New XmlSchemaCollection(db, "MySampleCollection")
xsc.Text = "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"NS2\"><xsd:element name=\"elem1\" type=\"xsd:integer\"/></xsd:schema>";
 'Create the XML schema collection on the instance of SQL Server.
xsc.Create()
Dim dt As DataType
dt = New DataType(xsc)

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")
$xsc = new-object Microsoft.SqlServer.Management.Smo.XmlSchemaCollection($db, "MySampleCollectfghion2")
$xsc.Text = "<xsd:schema xmlns:xsd=\`"http://www.w3.org/2001/XMLSchema\`" targetNamespace=\`"NS2\`"><xsd:element name=\`"elem1\`" type=\`"xsd:integer\`"/></xsd:schema>"
$xsc.Create()
$dt = new-object Microsoft.SqlServer.Management.Smo.DataType($xsc)
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft