Skip to content

Executing input file that contain strings ending with \ #95

@npandrei

Description

@npandrei

I have a script file that contains strings ending with \. When running sqlcmd -S localhost -U sa -i script.sql, I get the following error:

Incorrect syntax near 'GO'.

These steps should allow to reproduce the issue:

docker run -it -u 0 -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=demo1234!' -p 1433:1433 mcr.microsoft.com/azure-sql-edge /bin/bash
# apt-get update && apt-get install -y curl gnupg2 software-properties-common
# curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
# apt-get update && apt-get install -y sqlcmd
# export SQLCMDPASSWORD=demo1234!
# /opt/mssql/bin/sqlservr &

wait for sql server to start

# sqlcmd -l 1 -S localhost -U sa -Q "SELECT 1"

create script.sql with these contents

-- script.sql


USE [master]
GO
IF DB_ID (N'demo') IS NOT NULL
DROP DATABASE [demo];
GO
CREATE DATABASE [demo]
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled\'))
begin
EXEC [demo].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
# sqlcmd -S localhost -U sa -i script.sql

and you should see the Incorrect syntax near 'GO'. error.

Any thoughts on what I can do to overcome this issue ?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions