Local Environment: Windows2003 + sql2008r2 + SQL script file containing Chinese Characters
Experience Summary: SQL script file encoding is best to save into gb2312, rather than UTF-8
Start -- run -- cmd
C: \ Documents ents and Settings \ Administrator>
Osql-U sa-P 123456-s 192.168.1.28-D testdb-r-e-I "C: \ sp_insert_user. SQL"-o "C: \ errorinfo.txt"
A bunch of errors occur:
1> 2> 3> [SQL Server native Client 10.0] incorrect count field or incorrect syntax
Why? -Why are there too many attempts? If exists
Solution:
Run SQL Server Management studio, open the "C: \ sp_insert_user. SQL" SQL script file, and select "Save as" encoded as gb2312.
Run the osql command again.
C: \ Documents ents and Settings \ Administrator>
Osql-U sa-P 123456-s 192.168.1.28-D testdb-r-e-I "C: \ sp_insert_user. SQL"-o "C: \ errorinfo.txt"
Running successful
Other solutions such as "changing the MS-DOS code page" failed:
C: \ Documents ents and Settings \ Administrator> chcp 936
C: \ Documents ents and Settings \ Administrator> chcp 65001