zoukankan      html  css  js  c++  java
  • osql执行SQL脚本内容包含中文时出现乱码问题的解决办法

    本机环境:Windows2003 + SQL2008R2 + 包含中文的SQL脚本文件

    经验小结:SQL脚本文件编码最好是存成GB2312的,而不是UTF-8

    开始--运行--CMD

    C:\Documents 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"

    出现一堆错误:

    1> 2> 3> [SQL Server Native Client 10.0]COUNT 字段不正确或语法错误
    锘?-濡傛灉瀛樺偍杩囩▼宸插瓨鍦ㄥ垯鍏堝垹闄?if exists


    解决办法:
    运行SQL Server Management Studio后打开"C:\sp_Insert_User.sql"SQL脚本文件,选择“另存为”编码为GB2312。

    重新运行OSQL命令
    C:\Documents 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"

    运行成功

    其它解决办法如"改变MS-DOS代码页"尝试过不起作用:

    C:\Documents and Settings\Administrator>chcp 936

    C:\Documents and Settings\Administrator>chcp 65001

  • 相关阅读:
    poj 1035 (Spell checker )
    poj 3080 (暴力 strstr)
    kmp 模版
    匈牙利算法模版
    poj 1274 The Perfect Stall (最大匹配)
    hdu 1083 Courses(二分图 )
    pku 3363(内部测试赛)
    Linux 下联网脚本文件
    Qt 多国语言
    引用和引用参数
  • 原文地址:https://www.cnblogs.com/xqf222/p/3306730.html
Copyright © 2011-2022 走看看