Mapping Binary Data

On singleton selects and cursor fetches, SQL Server binary, varbinary, and image columns are mapped to C host variable declared as character arrays without any data conversion. The host variable is treated as a byte array. In order 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 datatype 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.