SQLServer Binary Data with ActiveRecord and JDBC

Posted by John Duff on Stack Overflow See other posts from Stack Overflow or by John Duff
Published on 2010-03-30T18:45:21Z Indexed on 2010/04/03 15:23 UTC
Read the original article Hit count: 405

I'm using the activerecord-jdbc-adapter with ActiveRecord to be able to access a SQLServer database for Rails Application running under jRuby and am having trouble inserting binary data. The Exception I am getting is below. Note I just have a blurb for the binary data from the fixtures that was working fine for MySQL.

ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: Operand type clash: nvarchar is incompatible with image: 
INSERT INTO blobstorage_datachunks ([id], [datafile_id], [chunk_number], [data]) VALUES (369397133, 663419003, 0, N'GIF89a@')

When I created the tables the migration had binary and SQLServer used Image instead. We're using Rails 2.3.5, SQLServer Express 2008. What I'm looking for is a way to get the binary data into SQLServer with ActiveRecord.

Thanks in advance for the help.

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about sql-server