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

Mssql: Incorrect syntax near the keyword 'with'. plugin syntax problem. #81

Open
Exist2Resist opened this issue Jul 20, 2021 · 1 comment

Comments

@Exist2Resist
Copy link

Exist2Resist commented Jul 20, 2021

When backing up I get
Msg 102, Level 15, State 1, Server mssql-server-1-lrjmh, Line 1 Incorrect syntax near '-'. Msg 319, Level 15, State 1, Server mssql-server-1-lrjmh, Line 1 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

I tracked this to the backup.mssql.plugin line 19:
sqlcmd -S ${_hostname}${_portArg} -U ${_username} -P ${_password} -Q "BACKUP DATABASE ${_database} TO DISK = N'${_fileName}' WITH NOFORMAT, NOINIT, SKIP, NOREWIND, NOUNLOAD, STATS = 10"

The database name should be wrapped in square [ ] brackets, as per Microsoft documentation.

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-backup-and-restore-database?view=sql-server-ver15

Without it backup gets created but are empty.

Should be
sqlcmd -S ${_hostname}${_portArg} -U ${_username} -P ${_password} -Q "BACKUP DATABASE [${_database}] TO DISK = N'${_fileName}' WITH NOFORMAT, NOINIT, SKIP, NOREWIND, NOUNLOAD, STATS = 10"

Haven't tried restore yet, might also need to make changes to that.

@WadeBarnes
Copy link
Member

Feel free to submit a PR with your changes once you've completed your testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants