SqlMetaData Class

SqlMetaData Class

 

Specifies and retrieves metadata information from parameters and columns of SqlDataRecord objects. This class cannot be inherited.

Namespace:   Microsoft.SqlServer.Server
Assembly:  System.Data (in System.Data.dll)

System.Object
  Microsoft.SqlServer.Server.SqlMetaData

public sealed class SqlMetaData

NameDescription
System_CAPS_pubmethodSqlMetaData(String, SqlDbType)

Initializes a new instance of the SqlMetaData class with the specified column name and type.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, and default server. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Byte, Byte)

Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, scale, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Int64)

Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type)

Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT).

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT). This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions)

Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, and compare options.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, compare options, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, String, String, String)

Initializes a new instance of the SqlMetaData class with the specified column name, type, database name, owning schema, and object name.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, database name, owning schema, object name, and default server. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Type)

Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT).

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Type, String)

Initializes a new instance of the SqlMetaData class with the specified column name, user-defined type (UDT), and SQLServer type.

System_CAPS_pubmethodSqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32)

Initializes a new instance of the SqlMetaData class with the specified column name, type, user-defined type, SQL Server type, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

NameDescription
System_CAPS_pubpropertyCompareOptions

Gets the comparison rules used for the column or parameter.

System_CAPS_pubpropertyDbType

Gets the data type of the column or parameter.

System_CAPS_pubpropertyIsUniqueKey

Indicates if the column in the table-valued parameter is unique.

System_CAPS_pubpropertyLocaleId

Gets the locale ID of the column or parameter.

System_CAPS_pubpropertySystem_CAPS_staticMax

Gets the length of text, ntext, and image data types.

System_CAPS_pubpropertyMaxLength

Gets the maximum length of the column or parameter.

System_CAPS_pubpropertyName

Gets the name of the column or parameter.

System_CAPS_pubpropertyPrecision

Gets the precision of the column or parameter.

System_CAPS_pubpropertyScale

Gets the scale of the column or parameter.

System_CAPS_pubpropertySortOrder

Returns the sort order for a column.

System_CAPS_pubpropertySortOrdinal

Returns the ordinal of the sort column.

System_CAPS_pubpropertySqlDbType

Gets the data type of the column or parameter.

System_CAPS_pubpropertyType

Gets the common language runtime (CLR) type of a user-defined type (UDT).

System_CAPS_pubpropertyTypeName

Gets the three-part name of the user-defined type (UDT) or the SQL Server type represented by the instance.

System_CAPS_pubpropertyUseServerDefault

Reports whether this column should use the default server value.

System_CAPS_pubpropertyXmlSchemaCollectionDatabase

Gets the name of the database where the schema collection for this XML instance is located.

System_CAPS_pubpropertyXmlSchemaCollectionName

Gets the name of the schema collection for this XML instance.

System_CAPS_pubpropertyXmlSchemaCollectionOwningSchema

Gets the owning relational schema where the schema collection for this XML instance is located.

NameDescription
System_CAPS_pubmethodAdjust(Boolean)

Validates the specified Boolean value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Byte)

Validates the specified Byte value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Byte[])

Validates the specified array of Byte values against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Char)

Validates the specified Char value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Char[])

Validates the specified array of Char values against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(DateTime)

Validates the specified DateTime value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(DateTimeOffset)

Validates the specified DateTimeOffset value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Decimal)

Validates the specified Decimal value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Double)

Validates the specified Double value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Guid)

Validates the specified Guid value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Int16)

Validates the specified Int16 value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Int32)

Validates the specified Int32 value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Int64)

Validates the specified Int64 value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Object)

Validates the specified Object value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(Single)

Validates the specified Single value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlBinary)

Validates the specified SqlBinary value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlBoolean)

Validates the specified SqlBoolean value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlByte)

Validates the specified SqlByte value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlBytes)

Validates the specified SqlBytes value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlChars)

Validates the specified SqlChars value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlDateTime)

Validates the specified SqlDateTime value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlDecimal)

Validates the specified SqlDecimal value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlDouble)

Validates the specified SqlDouble value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlGuid)

Validates the specified SqlGuid value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlInt16)

Validates the specified SqlInt16 value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlInt32)

Validates the specified SqlInt32 value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlInt64)

Validates the specified SqlInt64 value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlMoney)

Validates the specified SqlMoney value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlSingle)

Validates the specified SqlSingle value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlString)

Validates the specified SqlString value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(SqlXml)

Validates the specified SqlXml value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(String)

Validates the specified String value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodAdjust(TimeSpan)

Validates the specified TimeSpan value against the metadata, and adjusts the value if necessary.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticInferFromValue(Object, String)

Infers the metadata from the specified object and returns it as a SqlMetaData instance.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The following example shows the creation of several SqlMetaData objects, which describe the column metadata of a record, and the creation of a SqlDataRecord. The column values of the SqlDataRecord are set and the SqlDataRecord is sent to the calling program using the SqlContext class.

[Microsoft.SqlServer.Server.SqlProcedure]
public static void CreateNewRecord()
{
   // Variables.
   SqlMetaData column1Info;
   SqlMetaData column2Info;
   SqlMetaData column3Info;
   SqlDataRecord record;

   // Create the column metadata.
   column1Info = new SqlMetaData("Column1", SqlDbType.NVarChar, 12);
   column2Info = new SqlMetaData("Column2", SqlDbType.Int);
   column3Info = new SqlMetaData("Column3", SqlDbType.DateTime);

   // Create a new record with the column metadata.      
   record = new SqlDataRecord(new SqlMetaData[] { column1Info, 
                                                  column2Info, 
                                                  column3Info });

   // Set the record fields.
   record.SetString(0, "Hello World!");
   record.SetInt32(1, 42);
   record.SetDateTime(2, DateTime.Now);

   // Send the record to the calling program.
   SqlContext.Pipe.Send(record);
}

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft