Skip to content

Latest commit

 

History

History
50 lines (43 loc) · 6.43 KB

data-type-mapping-in-itabledefinition.md

File metadata and controls

50 lines (43 loc) · 6.43 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Data type mapping in ITableDefinition (Native Client OLE DB provider)
Data type mapping in ITableDefinition (Native Client OLE DB provider)
markingmyname
maghan
03/14/2017
sql
native-client
reference
mapping data types [OLE DB]
SQL Server Native Client OLE DB provider, data types
ITableDefinition interface
DBCOLUMNDESC structure
data types [OLE DB]
CreateTable function
OLE DB, data types

SQL Server Native Client Data Type Mapping in ITableDefinition

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW]

When creating tables by using the ITableDefinition::CreateTable function, the [!INCLUDEssNoVersion] Native Client OLE DB provider consumer can specify [!INCLUDEssNoVersion] data types in the pwszTypeName member of the DBCOLUMNDESC array that is passed. If the consumer specifies the data type of a column by name, OLE DB data type mapping, represented by the wType member of the DBCOLUMNDESC structure, is ignored.

When specifying new column data types with OLE DB data types using the DBCOLUMNDESC structure wType member, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps OLE DB data types as follows.

OLE DB data type SQL Server

data type
Additional information
DBTYPE_BOOL bit
DBTYPE_BYTES binary, varbinary, image, or varbinary(max) The [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the ulColumnSize member of the DBCOLUMNDESC structure. Based on the value, and version of the [!INCLUDEssNoVersion] instance, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to image.

If the value of ulColumnSize is smaller than the maximum length of a binary data type column, then the [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the DBCOLUMNDESC rgPropertySets member. If DBPROP_COL_FIXEDLENGTH is VARIANT_TRUE, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to binary. If the value of the property is VARIANT_FALSE, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to varbinary. In either case, the DBCOLUMNDESC ulColumnSize member determines the width of the SQL Server column created.
DBTYPE_CY money
DBTYPE_DBTIMESTAMP datetime
DBTYPE_GUID uniqueidentifier
DBTYPE_I2 smallint
DBTYPE_I4 int
DBTYPE_NUMERIC numeric The [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the DBCOLUMNDESC bPrecision and bScale members to determine precision and scale for the numeric column.
DBTYPE_R4 real
DBTYPE_R8 float
DBTYPE_STR char, varchar, text, or varchar(max) The [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the ulColumnSize member of the DBCOLUMNDESC structure. Based on the value and version of the [!INCLUDEssNoVersion] instance, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to text.

If the value of ulColumnSize is smaller than the maximum length of a multibyte character data type column, then the [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the DBCOLUMNDESC rgPropertySets member. If DBPROP_COL_FIXEDLENGTH is VARIANT_TRUE, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to char. If the value of the property is VARIANT_FALSE, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to varchar. In either case, the DBCOLUMNDESC ulColumnSize member determines the width of the [!INCLUDEssNoVersion] column created.
DBTYPE_UDT UDT The following information is used in DBCOLUMNDESC structures by ITableDefinition::CreateTable when UDT columns are required:

pwSzTypeName is ignored.

rgPropertySets must include a DBPROPSET_SQLSERVERCOLUMN property set as described in the section on DBPROPSET_SQLSERVERCOLUMN, in Using User-Defined Types.
DBTYPE_UI1 tinyint
DBTYPE_WSTR nchar, nvarchar, ntext, or nvarchar(max) The [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the ulColumnSize member of the DBCOLUMNDESC structure. Based on the value, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to ntext.

If the value of ulColumnSize is smaller than the maximum length of a Unicode character data type column, then the [!INCLUDEssNoVersion] Native Client OLE DB provider inspects the DBCOLUMNDESC rgPropertySets member. If DBPROP_COL_FIXEDLENGTH is VARIANT_TRUE, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to nchar. If the value of the property is VARIANT_FALSE, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps the type to nvarchar. In either case, the DBCOLUMNDESC ulColumnSize member determines the width of the [!INCLUDEssNoVersion] column created.
DBTYPE_XML XML

Note

When creating a new table, the [!INCLUDEssNoVersion] Native Client OLE DB provider maps only the OLE DB data type enumeration values specified in the preceding table. Attempting to create a table with a column of any other OLE DB data type generates an error.

See Also

Data Types (OLE DB)