SqlMetaData Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
-
SqlMetaData
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.
// using Microsoft.Data.SqlClient.Server;
[Microsoft.Data.SqlClient.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);
}
Constructors
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, 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, Byte, Byte) |
Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale. |
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, 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, 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, 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, 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) |
Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length. |
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, 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, 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. |
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) |
Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT). |
SqlMetaData(String, SqlDbType) |
Initializes a new instance of the SqlMetaData class with the specified column name and type. |
Properties
CompareOptions |
Gets the comparison rules used for the column or parameter. |
DbType |
Gets the data type of the column or parameter. |
IsUniqueKey |
Indicates if the column in the table-valued parameter is unique. |
LocaleId |
Gets the locale ID of the column or parameter. |
Max |
Gets the length of |
MaxLength |
Gets the maximum length of the column or parameter. |
Name |
Gets the name of the column or parameter. |
Precision |
Gets the precision of the column or parameter. |
Scale |
Gets the scale of the column or parameter. |
SortOrder |
Returns the sort order for a column. |
SortOrdinal |
Returns the ordinal of the sort column. |
SqlDbType |
Gets the data type of the column or parameter. |
Type |
Gets the common language runtime (CLR) type of a user-defined type (UDT). |
TypeName |
Gets the three-part name of the user-defined type (UDT) or the SQL Server type represented by the instance. |
UseServerDefault |
Reports whether this column should use the default server value. |
XmlSchemaCollectionDatabase |
Gets the name of the database where the schema collection for this XML instance is located. |
XmlSchemaCollectionName |
Gets the name of the schema collection for this XML instance. |
XmlSchemaCollectionOwningSchema |
Gets the owning relational schema where the schema collection for this XML instance is located. |
Methods
Adjust(Boolean) |
Validates the specified Boolean value against the metadata, and adjusts the value if necessary. |
Adjust(Byte) |
Validates the specified Byte value against the metadata, and adjusts the value if necessary. |
Adjust(Byte[]) |
Validates the specified array of Byte values against the metadata, and adjusts the value if necessary. |
Adjust(Char) |
Validates the specified Char value against the metadata, and adjusts the value if necessary. |
Adjust(Char[]) |
Validates the specified array of Char values against the metadata, and adjusts the value if necessary. |
Adjust(DateTime) |
Validates the specified DateTime value against the metadata, and adjusts the value if necessary. |
Adjust(DateTimeOffset) |
Validates the specified DateTimeOffset value against the metadata, and adjusts the value if necessary. |
Adjust(Decimal) |
Validates the specified Decimal value against the metadata, and adjusts the value if necessary. |
Adjust(Double) |
Validates the specified Double value against the metadata, and adjusts the value if necessary. |
Adjust(Guid) |
Validates the specified Guid value against the metadata, and adjusts the value if necessary. |
Adjust(Int16) |
Validates the specified Int16 value against the metadata, and adjusts the value if necessary. |
Adjust(Int32) |
Validates the specified Int32 value against the metadata, and adjusts the value if necessary. |
Adjust(Int64) |
Validates the specified Int64 value against the metadata, and adjusts the value if necessary. |
Adjust(Object) |
Validates the specified Object value against the metadata, and adjusts the value if necessary. |
Adjust(Single) |
Validates the specified Single value against the metadata, and adjusts the value if necessary. |
Adjust(SqlBinary) |
Validates the specified SqlBinary value against the metadata, and adjusts the value if necessary. |
Adjust(SqlBoolean) |
Validates the specified SqlBoolean value against the metadata, and adjusts the value if necessary. |
Adjust(SqlByte) |
Validates the specified SqlByte value against the metadata, and adjusts the value if necessary. |
Adjust(SqlBytes) |
Validates the specified SqlBytes value against the metadata, and adjusts the value if necessary. |
Adjust(SqlChars) |
Validates the specified SqlChars value against the metadata, and adjusts the value if necessary. |
Adjust(SqlDateTime) |
Validates the specified SqlDateTime value against the metadata, and adjusts the value if necessary. |
Adjust(SqlDecimal) |
Validates the specified SqlDecimal value against the metadata, and adjusts the value if necessary. |
Adjust(SqlDouble) |
Validates the specified SqlDouble value against the metadata, and adjusts the value if necessary. |
Adjust(SqlGuid) |
Validates the specified SqlGuid value against the metadata, and adjusts the value if necessary. |
Adjust(SqlInt16) |
Validates the specified SqlInt16 value against the metadata, and adjusts the value if necessary. |
Adjust(SqlInt32) |
Validates the specified SqlInt32 value against the metadata, and adjusts the value if necessary. |
Adjust(SqlInt64) |
Validates the specified SqlInt64 value against the metadata, and adjusts the value if necessary. |
Adjust(SqlMoney) |
Validates the specified SqlMoney value against the metadata, and adjusts the value if necessary. |
Adjust(SqlSingle) |
Validates the specified SqlSingle value against the metadata, and adjusts the value if necessary. |
Adjust(SqlString) |
Validates the specified SqlString value against the metadata, and adjusts the value if necessary. |
Adjust(SqlXml) |
Validates the specified SqlXml value against the metadata, and adjusts the value if necessary. |
Adjust(String) |
Validates the specified String value against the metadata, and adjusts the value if necessary. |
Adjust(TimeSpan) |
Validates the specified TimeSpan value against the metadata, and adjusts the value if necessary. |
InferFromValue(Object, String) |
Infers the metadata from the specified object and returns it as a SqlMetaData instance. |