First of all, I speak about MS SQL Server. I don't know about other servers.
Second, when I say "short column", I mean column with a width of less than 255 bytes.
1. I can't use String variable to write data into short binary column. I must use Long String variable and call SqlSetLongBindDatatype(n, 23) function, otherwise I get sql error 26.
However, this is not a problem, though it's confusing.
2. On the other hand, I can't read data from short binary column into Long String variable. I must use Short variable, otherwise I get sql error on data fetching.
3. As you can see in attached test case last byte of written data was lost on write phase. Well, this is well-known feature (or bug?), and not only for String, but for Long String too. I should write one byte more. It's troublesome.
4. Well, I use String variable. And what I have in a result? I have not a binary data, but unicode string - double-wided and with zero terminator. This is not what I want to get. As I understand, I have no way to get original binary data. And this is a real issue.
Well, in reality I almost never use short binary columns to store data, but in some cases I read large binary columns by chunks:
Code: Select all
select cast(substring(data, 1, 254) as varbinary(254)) from ...
The test case is attached. If you want to run this test app, you must properly inintialize SqlDatabase, SqlUser and SqlPassword variables at SAM_AppStartup section.
Best regards, Vladimir.