Udostępnij za pośrednictwem


Metoda UserDefinedType (String, String)

Zwraca obiekt, który reprezentuje określony typ z określonym schematem.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Syntax

'Deklaracja
Public Shared Function UserDefinedType ( _
    type As String, _
    schema As String _
) As DataType
'Użycie
Dim type As String
Dim schema As String
Dim returnValue As DataType

returnValue = DataType.UserDefinedType(type, _
    schema)
public static DataType UserDefinedType(
    string type,
    string schema
)
public:
static DataType^ UserDefinedType(
    String^ type, 
    String^ schema
)
static member UserDefinedType : 
        type:string * 
        schema:string -> DataType 
public static function UserDefinedType(
    type : String, 
    schema : String
) : DataType

Parameters

Wartość zwracana

Typ: Microsoft.SqlServer.Management.Smo. . :: . .DataType
A DataType wartość obiektu.

Przykłady

Poniższy przykład kodu pokazuje, jak utworzyć typ zdefiniowany przez użytkownika.

C#

Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2008R2"];
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("AdventureWorks2008R2")
$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")