DataType DataType DataType Constructors

Definition

Overloads

DataType() DataType() DataType()

Initializes a new instance of the DataType class.

DataType(SqlDataType, String, String) DataType(SqlDataType, String, String)

Initializes a new instance of the DataType class based on a specified SQL Server data type with the specified type and schema.

DataType(SqlDataType, String) DataType(SqlDataType, String)

Initializes a new instance of the DataType class based on a specified SQL Server data type with the specified type.

DataType(SqlDataType, Int32) DataType(SqlDataType, Int32)

Initializes a new instance of the DataType class based on a specified SQL Server data type with specified precision or maximum length.

DataType(XmlSchemaCollection) DataType(XmlSchemaCollection)

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

DataType(SqlDataType, Int32, Int32) DataType(SqlDataType, Int32, Int32)

Initializes a new instance of the DataType class based on a specified SQL Server data type with the specified precision and scale.

DataType(UserDefinedTableType) DataType(UserDefinedTableType)

Initializes a new instance of the DataType class based on a specified user-defined table type.

DataType(UserDefinedDataType) DataType(UserDefinedDataType)

Initializes a new instance of the DataType class based on a specified user-defined data type.

DataType(SqlDataType) DataType(SqlDataType)

Initializes a new instance of the DataType class based on a specified SQL Server data type.

DataType(UserDefinedType) DataType(UserDefinedType)

Initializes a new instance of the DataType class based on a specified user-defined type.

DataType() DataType() DataType()

Initializes a new instance of the DataType class.

public:
 DataType();
public DataType ();
Public Sub New ()

Examples

Visual Basic

'Declare and create a DataType object variable.  
Dim dt As DataType  
dt = New DataType  

PowerShell

$dt = new-object Microsoft.SqlServer.Management.Smo.DataType  

Remarks

The default constructor initializes any fields to their default values.

DataType(SqlDataType, String, String) DataType(SqlDataType, String, String)

Initializes a new instance of the DataType class based on a specified SQL Server data type with the specified type and schema.

public:
 DataType(Microsoft::SqlServer::Management::Smo::SqlDataType sqlDataType, System::String ^ type, System::String ^ schema);
public DataType (Microsoft.SqlServer.Management.Smo.SqlDataType sqlDataType, string type, string schema);
Parameters
sqlDataType
SqlDataType SqlDataType SqlDataType

A SqlDataType object value that specifies the SQL Server data type.

type
String String String

A String value that specifies the type of data type.

schema
String String String

A String value that specifies the schema of the data type.

Examples

Visual Basic

'Declare and create a DataType object variable.  
Dim dt As DataType  
dt = New DataType(SqlDataType.  

PowerShell

$dt = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::  

DataType(SqlDataType, String) DataType(SqlDataType, String)

Initializes a new instance of the DataType class based on a specified SQL Server data type with the specified type.

public:
 DataType(Microsoft::SqlServer::Management::Smo::SqlDataType sqlDataType, System::String ^ type);
public DataType (Microsoft.SqlServer.Management.Smo.SqlDataType sqlDataType, string type);
Parameters
sqlDataType
SqlDataType SqlDataType SqlDataType

A SqlDataType object value that specifies the SQL Server data type.

type
String String String

A String value that specifies the type of data type.

Examples

Visual Basic

'Declare and create a DataType object variable.  
Dim dt As DataType  
dt = New DataType(SqlDataType.  

PowerShell

$dt = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::  

DataType(SqlDataType, Int32) DataType(SqlDataType, Int32)

Initializes a new instance of the DataType class based on a specified SQL Server data type with specified precision or maximum length.

public:
 DataType(Microsoft::SqlServer::Management::Smo::SqlDataType sqlDataType, int precisionOrMaxLengthOrScale);
public DataType (Microsoft.SqlServer.Management.Smo.SqlDataType sqlDataType, int precisionOrMaxLengthOrScale);
Parameters
sqlDataType
SqlDataType SqlDataType SqlDataType

A SqlDataType object value that specifies the SQL Server data type.

precisionOrMaxLengthOrScale
Int32 Int32 Int32

An Int32 value that specifies the precision for numeric SQL Server data types and maximum length for text based SQL Server data types.

Examples

Visual Basic

Dim dt As DataType  
dt = New DataType(SqlDataType.  

PowerShell

$dt = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::  

DataType(XmlSchemaCollection) DataType(XmlSchemaCollection)

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

public:
 DataType(Microsoft::SqlServer::Management::Smo::XmlSchemaCollection ^ xmlSchemaCollection);
public DataType (Microsoft.SqlServer.Management.Smo.XmlSchemaCollection xmlSchemaCollection);
Parameters
xmlSchemaCollection
XmlSchemaCollection XmlSchemaCollection XmlSchemaCollection

A XmlSchemaCollection object variable that specifies an XML schema collection.

Examples

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)  

DataType(SqlDataType, Int32, Int32) DataType(SqlDataType, Int32, Int32)

Initializes a new instance of the DataType class based on a specified SQL Server data type with the specified precision and scale.

public:
 DataType(Microsoft::SqlServer::Management::Smo::SqlDataType sqlDataType, int precision, int scale);
public DataType (Microsoft.SqlServer.Management.Smo.SqlDataType sqlDataType, int precision, int scale);
Parameters
sqlDataType
SqlDataType SqlDataType SqlDataType

A SqlDataType object value that specifies the SQL Server data type.

precision
Int32 Int32 Int32

An Int32 value that specifies the precision for numeric SQL Server data types.

scale
Int32 Int32 Int32

An Int32 value that specifies the scale for numeric SQL Server data types.

Examples

Visual Basic

'Declare and create a DataType object variable.  
Dim dt As DataType  
dt = New DataType(SqlDataType.Decimal, 3, 3)  

PowerShell

$dt = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::Decimal, 3, 3)  

DataType(UserDefinedTableType) DataType(UserDefinedTableType)

Initializes a new instance of the DataType class based on a specified user-defined table type.

public:
 DataType(Microsoft::SqlServer::Management::Smo::UserDefinedTableType ^ userDefinedTableType);
public DataType (Microsoft.SqlServer.Management.Smo.UserDefinedTableType userDefinedTableType);
Parameters
userDefinedTableType
UserDefinedTableType UserDefinedTableType UserDefinedTableType

A UserDefinedTableType object variable that specifies a user-defined type.

Examples

Working with Data Types

DataType(UserDefinedDataType) DataType(UserDefinedDataType)

Initializes a new instance of the DataType class based on a specified user-defined data type.

public:
 DataType(Microsoft::SqlServer::Management::Smo::UserDefinedDataType ^ userDefinedDataType);
public DataType (Microsoft.SqlServer.Management.Smo.UserDefinedDataType userDefinedDataType);
Parameters
userDefinedDataType
UserDefinedDataType UserDefinedDataType UserDefinedDataType

A UserDefinedDataTypeCollection object variable that specifies a user-defined data type.

Examples

Working with Data Types

Remarks

A user-defined data type is a type based on SQL Server data types.

DataType(SqlDataType) DataType(SqlDataType)

Initializes a new instance of the DataType class based on a specified SQL Server data type.

public:
 DataType(Microsoft::SqlServer::Management::Smo::SqlDataType sqlDataType);
public DataType (Microsoft.SqlServer.Management.Smo.SqlDataType sqlDataType);
Parameters
sqlDataType
SqlDataType SqlDataType SqlDataType

A SqlDataType object variable that specifies the SQL Server system data type.

Examples

Visual Basic

Dim dt As DataType  
dt = New DataType(SqlDataType.Int)  

PowerShell

$dt = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::Int)  

DataType(UserDefinedType) DataType(UserDefinedType)

Initializes a new instance of the DataType class based on a specified user-defined type.

public:
 DataType(Microsoft::SqlServer::Management::Smo::UserDefinedType ^ userDefinedType);
public DataType (Microsoft.SqlServer.Management.Smo.UserDefinedType userDefinedType);
Parameters
userDefinedType
UserDefinedType UserDefinedType UserDefinedType

A UserDefinedType object variable that specifies a user-defined type.

Examples

Working with Data Types

Remarks

A user-defined type is a type based on Microsoft .NET Framework types.

Applies to