# nvarchar error on mssql

**URL:** <https://forum.liquibase.org/t/nvarchar-error-on-mssql/525>\
**Category:** General Discussion\
**Created:** [May 14, 2010, 10:21pm UTC](https://forum.liquibase.org/t/nvarchar-error-on-mssql/525 "2010-05-14T22:21:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alana\_cable](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@alana\_cable](https://forum.liquibase.org/u/alana_cable)\
**Post date:** [May 14, 2010, 10:21pm UTC](https://forum.liquibase.org/t/nvarchar-error-on-mssql/525/1 "2010-05-14T22:21:00Z")

</div>

Hi,

The SQL generated when using nvarchar on MSSQL is not correct.&nbsp; Consider the following change sets

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 

&nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp;

The only difference is the second change set contains a nvarchar instead of a varchar.&nbsp;

The sql generated by these two changesets are:

CREATE TABLE [schema\_0514\_kKJO].[TestChange1] ( [id] BIGINT CONSTRAINT DF\_TestChange1\_id DEFAULT NULL, [name] VARCHAR(10) CONSTRAINT DF\_TestChange1\_name DEFAULT '' NOT NULL )

CREATE TABLE [schema\_0514\_kKJO].[TestChange2] (  
[id] BIGINT CONSTRAINT DF\_TestChange2\_id DEFAULT NULL,  
[name] nvarchar(32) CONSTRAINT DF\_TestChange2\_name DEFAULT NOT NULL)

The second changeset throws the following exception:

&nbsp; &nbsp; Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE [schema\_0514\_xe8z].[TestChange2] ([id] BIGINT CONSTRAINT DF\_TestChange2\_id DEFAULT NULL, [name] nvarchar(32) CONSTRAINT DF\_TestChange2\_name DEFAULT&nbsp; NOT NULL): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Caused By: Error executing SQL CREATE TABLE [schema\_0514\_xe8z].[TestChange2] ([id] BIGINT CONSTRAINT DF\_TestChange2\_id DEFAULT NULL, [name] nvarchar(32) CONSTRAINT DF\_TestChange2\_name DEFAULT&nbsp; NOT NULL): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Caused By: Incorrect syntax near the keyword 'NOT'.

In the case of the varchar, the default has an empty quote.&nbsp; This is missing in the nvarchar changeset, causing the error.

Hope you can get this fixed soon.  
Thanks,  
Alana

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [May 14, 2010, 10:21pm UTC](https://forum.liquibase.org/t/nvarchar-error-on-mssql/525/2 "2010-05-14T22:21:00Z")

</div>

What version of liquibase are you running against?

Nathan

---

<div class="post-metadata">

**Author:** ![alana\_cable](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@alana\_cable](https://forum.liquibase.org/u/alana_cable)\
**Post date:** [May 14, 2010, 10:21pm UTC](https://forum.liquibase.org/t/nvarchar-error-on-mssql/525/3 "2010-05-14T22:21:00Z")

</div>

I am using 2.0 build 202.

Thanks,  
Alana

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [May 14, 2010, 10:21pm UTC](https://forum.liquibase.org/t/nvarchar-error-on-mssql/525/4 "2010-05-14T22:21:00Z")

</div>

I created [http://liquibase.jira.com/browse/CORE-614,](http://liquibase.jira.com/browse/CORE-614,) it will be fixed for the next 2.0 RC

Nathan

---

<div class="post-metadata">

**Author:** ![joanpujol](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@joanpujol](https://forum.liquibase.org/u/joanpujol)\
**Post date:** [May 14, 2010, 10:21pm UTC](https://forum.liquibase.org/t/nvarchar-error-on-mssql/525/5 "2010-05-14T22:21:00Z")

</div>

I upload a patch in current 2.0 trunk [http://ci.ops4j.org/browse/LQB-DEF/latest/artifact](http://ci.ops4j.org/browse/LQB-DEF/latest/artifact)  
Can you try if it works?
