Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Mapping Binary Data

SQL Server 2000

On singleton SELECT statements and cursor fetches, Microsoft® SQL Server™ 2000 binary, varbinary, and image columns are mapped to C host variables declared as character arrays without any data conversion. The host variable is treated as a byte array. To retrieve the hexadecimal character representation of a binary, varbinary, or image column, use the Transact-SQL CONVERT function on the column.

When input, a C character array data type can be mapped to a SQL Server binary, varbinary, or image column by using dynamic SQL statements. To do this, use two question marks (??) as parameter markers. The data format on input is the raw binary data (not its hexadecimal character representation.) If you include at least one space between the parameter marker and its indicator, you can use indicator variables. You cannot use static SQL statements to map binary data on input parameters.

You can use static SQL statements to map binary data on input parameters. However, you will need to manually modify the generated .c code to specify the length of the variable. For example, if you declare the void *pChar variable, the precompiler will generate a sqlasetv to set the parameter length to unknown by putting -1 as the parameter length. The third parameter of -1 indicates that this is a pointer. You may have to modify this length to indicate proper size of data contained in pChar. The .c source can then be compiled and linked as usual.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.