>>I have a large character variable (400,000 bytes), the result of a FILETOSTR() operation. I want to INSERT this value into a SQL Server varbinary(MAX) column.
>>
>>This doesn't work:
>>lcFile = FILETOSTR( {some file} )
>>
>>lcSQL = "INSERT INTO dbo.SomeTable ( VarBinCol ) VALUES ( ?m.lcFile )"
>>
>>=SQLEXEC( MyHandle, m.lcSQL )
>>
>>* ODBC error:
>>* Error Message: [Connectivity error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Operand type clash: text is incompatible with varbinary(max)]
>>
>>I can do this with a remote view but I've already coded the routine using SPT. If there's some magic trick to make this work using SPT I'd prefer to use that.
>
>Did you try?
>
>lcSQL = "INSERT INTO dbo.SomeTable ( VarBinCol ) VALUES ( cast(?m.lcFile as varinary(max) )"
Nice idea, but:
ODBC Error Message: [[Microsoft][SQL Server Native Client 11.0][SQL Server]Explicit conversion from data type text to varbinary(max) is not allowed.]
According to what I've been able to find online, conversion from text to varbinary(max) is implicit (hence the error above).
https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql#large-value-data-typesI've looked at SQLSETPROP() for any connection properties that might affect this, I didn't see anything that might be applicable.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up