Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server migration batch terminator as first statement gives empty query error #1838

mpapetti opened this issue Nov 23, 2017 · 2 comments


Copy link

@mpapetti mpapetti commented Nov 23, 2017

What version of Flyway are you using?


Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)


What database are you using (type & version)?

SQL Server 2016

What operating system are you using?

Amazon linux

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

Tried to run a migration with the following as the first few lines:

 some comment

I ran flyway -url='mydburl/mydb' -locations='mylocation' migrate

What did you expect to see?

I expected the migration to run successfully

What did you see instead?

The migration ran fine when I removed GO. When I put GO as the first line of a migration, it will fail with the error below. Is it possible for flyway to ignore this line if no query exists before it? I suggest a simple regex to identify:

  • If a migration's GO or batch terminator (or configured terminator) has an actual query preceding it or just some comments
  • Based on previous, ignore the batch terminator if comments are found or run the query if it is found
SQL State  : HY000
Error Code : 0
Message    : The SQL statement must not be null or empty.
Location   : myMigration.sql 
Line       : 4
Statement  : 


Copy link

@axelfontaine axelfontaine commented Dec 18, 2017

This is now working. (Make sure to use the newly bundled MS driver)

axelfontaine added a commit to flyway/ that referenced this issue Dec 18, 2017
Copy link

@mpapetti mpapetti commented Dec 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants