0

My batch file started to write output to log file in Chinese. Code:

echo ============= >> D:\path\file.log
echo. >> D:\path\file.log
echo. >> D:\path\file.log
echo Import new data to table %date% D:\path\file.log
sqlcmd -S (local)\sqlexpress -E -d DB_Name -Q "exit(exec[dbo].[StoredProcedure])" >> D:\path\file.log

It worked fine for many months and all of a sudden it started to write the whole output in weird format like here:

 㴽㴽㴽㴽㴽㴽‽਍ഠ ਍浉潰瑲渠睥搠瑡⁡潴匠䍒剟䵅䑅彙䅒⁗慴汢⁥㤰〯⼲〲㘱ഠ ਍㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽਍ഠ刊浥摥⁹慄慴䰠湡楤杮娠湯㩥਍਍㐨㌶㔰爠睯⁳晡敦瑣摥ഩ

I saw this related question but it refers to a specific command issue as far as I understand. I would appreciate your help.


EDIT: After creating the batch file from scratch, the problem disappeared. Still don;t know what was the issue.

Community
  • 1
  • 1
  • Perhaps you saved the Batch file with UTF-8 encoding instead of the Ansi standard (that is not rare when using non-standard text editors). – Aacini Feb 10 '16 at 05:51
  • I see your point. Why the batch was working fine for many months and started that weird behavior without me touching it? Remains unknown. Thanks for contribution anyway. – Adrian Chrostowski Feb 10 '16 at 08:50
  • I had the same problem and the cause ended up being related to appending my log file, when I used a single > and over wrote the log it worked fine. – Justin Buser Apr 14 '16 at 21:24

2 Answers2

0

Please Change your Language Via Below Command and Write log again after that check your logs.

EXEC sp_configure 'default language', 23 RECONFIGURE

JavidRathod
  • 483
  • 2
  • 10
  • Hi, I have run that command on SQL Server, executed the batch, and still got China in my log... Moreover, only this batch has the problem. All other batches running sqlcmd on the same SQL Server give normal results. – Adrian Chrostowski Feb 09 '16 at 11:28
0

In my case resolution was simply recreating both the batch file and the log file. Make sure you save the files in correct encoding format too.

EDIT: After some more investigation I found out that script clearing the log file (deleting some lines) that I used once must have changed the encoding to UCS-2 Little Endian.