In a pre-build event, a batch file is executed to combine multiple SQL files into a single one.
It is done using this command :
COPY %@ProjectDir%\Migrations\*.sql %@ProjectDir%ContinuousDeployment\AllFilesMergedTogether.sql
Everything appear to work fine but somehow the result give an incorrect syntaxe error.
After two hours of investigation, it turn out the issue is caused by an invisible character that remain invisible even with notepad++.
Using an online website, the character has been spotted and is U+FEFF
has shown in following image.
Here are the two input scripts.
PRINT 'Script1'
PRINT 'Script2'
Here is the output given by the copy command.
PRINT 'Script1'
PRINT 'Script2'
Additional info :
- Batch file is encoded with UTF-8
- Input files are encoded with UTF-8-BOM
- Output file is encoded with UTF-8-BOM.
I'm not sure it is possible to change the encoding output of commandcopy
.
I've tried and failed.
What should be done to eradicate this extremely frustrating parasitic character?
It has turned out that changing encoding of input files to
ANSI
does fix the issue.No more pesky character(s).
Also, doing so does change the encoding of the result file to
UTF-8
instead ofUTF-8-BOM
which is great I believe.Encoding can be changed using Notepad++ as show in following picture.