DataType.UserDefinedType DataType.UserDefinedType DataType.UserDefinedType Method

Definition

Returns an object that represents the specified type.

Overloads

UserDefinedType(String) UserDefinedType(String) UserDefinedType(String)

Returns an object that represents the specified type.

UserDefinedType(String, String) UserDefinedType(String, String) UserDefinedType(String, String)

Returns an object that represents the specified type with the specified schema.

UserDefinedType(String) UserDefinedType(String) UserDefinedType(String)

Returns an object that represents the specified type.

public:
 static Microsoft::SqlServer::Management::Smo::DataType ^ UserDefinedType(System::String ^ type);
public static Microsoft.SqlServer.Management.Smo.DataType UserDefinedType (string type);
Public Shared Function UserDefinedType (type As String) As DataType
Parameters
type
String String String

A String value that specifies the type.

Returns

Examples

The following code example shows how to create a user-defined type.

C#

Server srv = new Server("(local)");  
Database db = srv.Databases["AdventureWorks2012"];  
Schema schema1 = new Schema(db, "ExampleSchema");  
schema1.Create();  
UserDefinedType udt = new UserDefinedTableType(db, "udt", "ExampleSchema");  
udt.Create();  
DataType userType = new DataType(SqlDataType.UserDefinedType, "udt");  

Powershell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = $srv.Databases.Item("AdventureWorks2012")  
$schema1 = new-object Microsoft.SqlServer.Management.Smo.Schema($db, "ExampleSchema")  
$schema1.Create()  
$udt = new-object Microsoft.SqlServer.Management.Smo.UserDefinedType($db, "udt", "ExampleSchema")  
$userTable = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::UserDefinedType, "udt")  

UserDefinedType(String, String) UserDefinedType(String, String) UserDefinedType(String, String)

Returns an object that represents the specified type with the specified schema.

public:
 static Microsoft::SqlServer::Management::Smo::DataType ^ UserDefinedType(System::String ^ type, System::String ^ schema);
public static Microsoft.SqlServer.Management.Smo.DataType UserDefinedType (string type, string schema);
Public Shared Function UserDefinedType (type As String, schema As String) As DataType
Parameters
type
String String String

A String value that specifies the type.

schema
String String String

A String value that specifies the schema.

Returns

Examples

The following code example shows how to create a user-defined type.

C#

Server srv = new Server("(local)");  
Database db = srv.Databases["AdventureWorks2012"];  
Schema schema1 = new Schema(db, "ExampleSchema");  
schema1.Create();  
UserDefinedType udt = new UserDefinedTableType(db, "udt", "ExampleSchema");  
udt.Create();  
DataType userType = new DataType(SqlDataType.UserDefinedType, "udt", "ExampleSchema");  

Powershell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = $srv.Databases.Item("AdventureWorks2012")  
$schema1 = new-object Microsoft.SqlServer.Management.Smo.Schema($db, "ExampleSchema")  
$schema1.Create()  
$udt = new-object Microsoft.SqlServer.Management.Smo.UserDefinedType($db, "udt", "ExampleSchema")  
$userTable = new-object Microsoft.SqlServer.Management.Smo.DataType([Microsoft.SqlServer.Management.Smo.SqlDataType]::UserDefinedType, "udt", "ExampleSchema")  

Applies to