# Unexpected error running Liquibase: Incorrect syntax near the keyword 'BY'

**URL:** <https://forum.liquibase.org/t/unexpected-error-running-liquibase-incorrect-syntax-near-the-keyword-by/7251>\
**Category:** Liquibase Development\
**Created:** [August 30, 2022, 2:39pm UTC](https://forum.liquibase.org/t/unexpected-error-running-liquibase-incorrect-syntax-near-the-keyword-by/7251 "2022-08-30T14:39:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gkoukas](https://avatars.discourse-cdn.com/v4/letter/g/fbc32d/32.png) [@gkoukas](https://forum.liquibase.org/u/gkoukas)\
**Post date:** [August 30, 2022, 2:39pm UTC](https://forum.liquibase.org/t/unexpected-error-running-liquibase-incorrect-syntax-near-the-keyword-by/7251/1 "2022-08-30T14:39:53Z")

</div>

Hello,  
I created a table in an MS SQL database with below script:

```auto
CREATE TABLE [dbo].[VersionHistory](
       [SID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
       [VersionNumberString] [nvarchar](max) NOT NULL,
       [UpdatedOn] [datetime] NOT NULL,
CONSTRAINT [PK_VersionHistory] PRIMARY KEY CLUSTERED 
(
       [SID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

```

Then I executed the command:

```auto
liquibase diff-changelog --diff-types=tables,functions,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints,data,storedprocedures,sequences

```

and created a changeLog File with the above table:

```auto
-- liquibase formatted sql

-- changeset giorgos:1661869491404-1
CREATE TABLE VersionHistory (SID INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, VersionNumberString NVARCHAR(MAX) NOT NULL, UpdatedOn TIMESTAMP NOT NULL, CONSTRAINT PK_VersionHistory PRIMARY KEY (SID));

```

But when I tried to execute the liquibase update command I got the following error:

```auto
Unexpected error running Liquibase: Incorrect syntax near the keyword 'BY'. [Failed SQL: (156) CREATE TABLE VersionHistory (SID INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, VersionNumberString NVARCHAR(MAX) NOT NULL, UpdatedOn TIMESTAMP NOT NULL, CONSTRAINT PK_VersionHistory PRIMARY KEY (SID))]

```

Even if I execute the above script to sql enterprise management studio I’m getting the same error “Incorrect syntax near the keyword ‘BY’”.  
Could anyone help me with this issue please?

Thanks in advance,  
George

---

<div class="post-metadata">

**Author:** ![tabbyfoo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/tabbyfoo/32/748_2.png) [@tabbyfoo](https://forum.liquibase.org/u/tabbyfoo)\
**Post date:** [September 20, 2022, 2:28am UTC](https://forum.liquibase.org/t/unexpected-error-running-liquibase-incorrect-syntax-near-the-keyword-by/7251/2 "2022-09-20T02:28:21Z")

</div>

> [@gkoukas](#):
>
> ```auto
> Unexpected error running Liquibase: Incorrect syntax near the keyword 'BY'. [Failed SQL: (156) CREATE TABLE VersionHistory (SID INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, VersionNumberString NVARCHAR(MAX) NOT NULL, UpdatedOn TIMESTAMP NOT NULL, CONSTRAINT PK_VersionHistory PRIMARY KEY (SID))]
> 
> ```

I found an accepted answer on [StackOverflow](https://stackoverflow.com/questions/35989586/liquibase-unexpected-error-running-liquibase-incorrect-syntax-near-up) that addresses this issue:

> This issue was addressed in two ways.
> 
> 1. appending `;` at the end of the trigger logic in the SQL file
> 2. adding `splitStatements="false" endDelimiter=";"` to the sqlFile parameters
