views:

34

answers:

1

I'm experimenting with Liquibase, trying to get it to copy one database to another. Unfortunately, I keep getting this error:

Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query.

The SQL it's generating is here:

CREATE TABLE [dbo].[Attachment] (
    [Applicantid] uniqueidentifier NOT NULL, 
    [Attachmentid] uniqueidentifier CONSTRAINT DF_Attachment_Attachmentid DEFAULT '(newid())' NOT NULL, 
    [AttachmentType] INT CONSTRAINT DF_Attachment_AttachmentType DEFAULT 0 NOT NULL, 
    [FileAttachment] image NOT NULL, 
    [FileName] ntext NOT NULL, 
    [FileType] nvarchar(125) NOT NULL, 
    [Filesize] INT NOT NULL, 
    [CCN] varbinary(8) CONSTRAINT DF_Attachment_CCN DEFAULT '0' NOT NULL, 
    [CreateDate] DATETIME CONSTRAINT DF_Attachment_CreateDate DEFAULT (getdate()) NOT NULL, 
    [LastUpdate] DATETIME CONSTRAINT DF_Attachment_LastUpdate DEFAULT (getdate()) NOT NULL, 
    CONSTRAINT [PK_Attachment] PRIMARY KEY (Attachmentid)
  ):
+1  A: 

Those liquibase project guys need to learn a few things about more recent versions of SQL Server - 2005 and up:

  • NTEXT is long been deprecated - use NVARCHAR(MAX) instead
  • IMAGE is long been deprecated, too - use VARBINARY(MAX) instead

(those datatypes would be OK if you're dealing with SQL Server 2000 or earlier, however).

Plus: just from that table definition, there's no way to be able to figure out why you get this error. Is this your original (source) table, or is this what Liquibase generates as a target table?? If so: any chance you can see / trace / inspect the SQL statements used to migrate the data from the old to the new table??

Maybe there's a varchar column there that you try to convert to varbinary implicitly...

marc_s
Liquibase homepage. - http://www.liquibase.org/
JNK
Thanks for the pointer on data types, the next version of liquibase will use the newer types
Nathan Voxland