SqlMetaData SqlMetaData SqlMetaData SqlMetaData Class

Definition

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

public ref class SqlMetaData sealed
public sealed class SqlMetaData
type SqlMetaData = class
Public NotInheritable Class SqlMetaData
Inheritance
SqlMetaDataSqlMetaDataSqlMetaDataSqlMetaData

Examples

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);
}
<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub CreateNewRecord()

   ' Variables.
   Dim column1Info As SqlMetaData 
   Dim column2Info As SqlMetaData
   Dim column3Info As SqlMetaData
   Dim record As SqlDataRecord

   ' 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)

End Sub

Constructors

SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType)

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

SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte)

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

SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64)

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

SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(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).

SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(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.

SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(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.

SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type)

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

SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String)

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

SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(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.

Properties

CompareOptions CompareOptions CompareOptions CompareOptions

Gets the comparison rules used for the column or parameter.

DbType DbType DbType DbType

Gets the data type of the column or parameter.

IsUniqueKey IsUniqueKey IsUniqueKey IsUniqueKey

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

LocaleId LocaleId LocaleId LocaleId

Gets the locale ID of the column or parameter.

Max Max Max Max

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

MaxLength MaxLength MaxLength MaxLength

Gets the maximum length of the column or parameter.

Name Name Name Name

Gets the name of the column or parameter.

Precision Precision Precision Precision

Gets the precision of the column or parameter.

Scale Scale Scale Scale

Gets the scale of the column or parameter.

SortOrder SortOrder SortOrder SortOrder

Returns the sort order for a column.

SortOrdinal SortOrdinal SortOrdinal SortOrdinal

Returns the ordinal of the sort column.

SqlDbType SqlDbType SqlDbType SqlDbType

Gets the data type of the column or parameter.

Type Type Type Type

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

TypeName TypeName TypeName TypeName

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

UseServerDefault UseServerDefault UseServerDefault UseServerDefault

Reports whether this column should use the default server value.

XmlSchemaCollectionDatabase XmlSchemaCollectionDatabase XmlSchemaCollectionDatabase XmlSchemaCollectionDatabase

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

XmlSchemaCollectionName XmlSchemaCollectionName XmlSchemaCollectionName XmlSchemaCollectionName

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

XmlSchemaCollectionOwningSchema XmlSchemaCollectionOwningSchema XmlSchemaCollectionOwningSchema XmlSchemaCollectionOwningSchema

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

Methods

Adjust(Boolean) Adjust(Boolean) Adjust(Boolean) Adjust(Boolean)

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

Adjust(Byte) Adjust(Byte) Adjust(Byte) Adjust(Byte)

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

Adjust(Byte[]) Adjust(Byte[]) Adjust(Byte[]) Adjust(Byte[])

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

Adjust(Char) Adjust(Char) Adjust(Char) Adjust(Char)

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

Adjust(Char[]) Adjust(Char[]) Adjust(Char[]) Adjust(Char[])

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

Adjust(DateTime) Adjust(DateTime) Adjust(DateTime) Adjust(DateTime)

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

Adjust(DateTimeOffset) Adjust(DateTimeOffset) Adjust(DateTimeOffset) Adjust(DateTimeOffset)

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

Adjust(Decimal) Adjust(Decimal) Adjust(Decimal) Adjust(Decimal)

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

Adjust(Double) Adjust(Double) Adjust(Double) Adjust(Double)

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

Adjust(Guid) Adjust(Guid) Adjust(Guid) Adjust(Guid)

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

Adjust(Int16) Adjust(Int16) Adjust(Int16) Adjust(Int16)

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

Adjust(Int32) Adjust(Int32) Adjust(Int32) Adjust(Int32)

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

Adjust(Int64) Adjust(Int64) Adjust(Int64) Adjust(Int64)

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

Adjust(Object) Adjust(Object) Adjust(Object) Adjust(Object)

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

Adjust(Single) Adjust(Single) Adjust(Single) Adjust(Single)

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

Adjust(SqlBinary) Adjust(SqlBinary) Adjust(SqlBinary) Adjust(SqlBinary)

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

Adjust(SqlBoolean) Adjust(SqlBoolean) Adjust(SqlBoolean) Adjust(SqlBoolean)

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

Adjust(SqlByte) Adjust(SqlByte) Adjust(SqlByte) Adjust(SqlByte)

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

Adjust(SqlBytes) Adjust(SqlBytes) Adjust(SqlBytes) Adjust(SqlBytes)

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

Adjust(SqlChars) Adjust(SqlChars) Adjust(SqlChars) Adjust(SqlChars)

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

Adjust(SqlDateTime) Adjust(SqlDateTime) Adjust(SqlDateTime) Adjust(SqlDateTime)

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

Adjust(SqlDecimal) Adjust(SqlDecimal) Adjust(SqlDecimal) Adjust(SqlDecimal)

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

Adjust(SqlDouble) Adjust(SqlDouble) Adjust(SqlDouble) Adjust(SqlDouble)

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

Adjust(SqlGuid) Adjust(SqlGuid) Adjust(SqlGuid) Adjust(SqlGuid)

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

Adjust(SqlInt16) Adjust(SqlInt16) Adjust(SqlInt16) Adjust(SqlInt16)

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

Adjust(SqlInt32) Adjust(SqlInt32) Adjust(SqlInt32) Adjust(SqlInt32)

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

Adjust(SqlInt64) Adjust(SqlInt64) Adjust(SqlInt64) Adjust(SqlInt64)

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

Adjust(SqlMoney) Adjust(SqlMoney) Adjust(SqlMoney) Adjust(SqlMoney)

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

Adjust(SqlSingle) Adjust(SqlSingle) Adjust(SqlSingle) Adjust(SqlSingle)

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

Adjust(SqlString) Adjust(SqlString) Adjust(SqlString) Adjust(SqlString)

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

Adjust(SqlXml) Adjust(SqlXml) Adjust(SqlXml) Adjust(SqlXml)

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

Adjust(String) Adjust(String) Adjust(String) Adjust(String)

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

Adjust(TimeSpan) Adjust(TimeSpan) Adjust(TimeSpan) Adjust(TimeSpan)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InferFromValue(Object, String) InferFromValue(Object, String) InferFromValue(Object, String) InferFromValue(Object, String)

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

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to