SqlMetaData Class
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
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
Sql |
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. |
Sql |
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. |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale. |
Sql |
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. |
Sql |
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. |
Sql |
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). |
Sql |
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. |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, and compare options. |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length. |
Sql |
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. |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name, type, database name, owning schema, and object name. |
Sql |
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. |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name, user-defined type (UDT), and SQLServer type. |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT). |
Sql |
Initializes a new instance of the SqlMetaData class with the specified column name and type. |
Compare |
Gets the comparison rules used for the column or parameter. |
Db |
Gets the data type of the column or parameter. |
Is |
Indicates if the column in the table-valued parameter is unique. |
Locale |
Gets the locale ID of the column or parameter. |
Max |
Gets the length of |
Max |
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. |
Sort |
Returns the sort order for a column. |
Sort |
Returns the ordinal of the sort column. |
Sql |
Gets the data type of the column or parameter. |
Type |
Gets the common language runtime (CLR) type of a user-defined type (UDT). |
Type |
Gets the three-part name of the user-defined type (UDT) or the SQL Server type represented by the instance. |
Use |
Reports whether this column should use the default server value. |
Xml |
Gets the name of the database where the schema collection for this XML instance is located. |
Xml |
Gets the name of the schema collection for this XML instance. |
Xml |
Gets the owning relational schema where the schema collection for this XML instance is located. |
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(Date |
Validates the specified DateTime value against the metadata, and adjusts the value if necessary. |
Adjust(Date |
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(Sql |
Validates the specified SqlBinary value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlBoolean value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlByte value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlBytes value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlChars value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlDateTime value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlDecimal value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlDouble value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlGuid value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlInt16 value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlInt32 value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlInt64 value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlMoney value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlSingle value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
Validates the specified SqlString value against the metadata, and adjusts the value if necessary. |
Adjust(Sql |
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(Time |
Validates the specified TimeSpan value against the metadata, and adjusts the value if necessary. |
Infer |
Infers the metadata from the specified object and returns it as a SqlMetaData instance. |
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |