SQL Server 2005 中文亂碼解決方法

2021-06-04 20:23:36 字數 843 閱讀 2602

中文存到資料庫中總是顯示亂碼。debug發現頁面中文到service都是正確的中文。

解決辦法:

1.關閉所有與此資料庫的相關連線或者會話或者相關程式

2.然後將 sql_latin1_general_cp1_ci_as 修改為 chinese_prc_ci_as (alter database

db_namecollate chinese_prc_ci_as) 屬性-》選項

3.將varchar型別修改為nvarchar 就沒問題了。或者。如果表裡面沒有資料的話,把錶結構重新建立,建表的時候需要注意不要帶「sql_latin1_general_cp1_ci_as」排序規則。

後來檢查資料庫連線字段,發現乙個引數

sendstringparametersasunicode=false

將其改為 sendstringparametersasunicode=true 問題解決。

查msdn資料

如果 sendstringparametersasunicode 屬性設定為「true」,則字串引數將以 unicode 格式傳送給伺服器。

如果 sendstringparametersasunicode 屬性設定為「false」,則字串引數將以非 unicode 格式(例如 ascii/mbcs 而不是 unicode)傳送給伺服器。

sendstringparametersasunicode 屬性的預設值為「true」。

在freetds進行設定,即可讓freetds生效。this is only used when compiled with freetds。mssql預設是不支援設定字符集的,只有安裝freetds的時候才能生效。

Sql Server 2005 中文亂碼 解決

至mr co 使用sql server2005的時候常常遇到中文字元為亂碼的情況,經過研究發現,設定sql的排序規則可以解決這個問題。1 登入伺服器開啟microsoft sql server management studio。2 在要修改的資料庫上單擊滑鼠右鍵,並選擇 屬性 3 在彈出的資料庫屬...

sql server 2005中的output子句

今天看了下sql server 2005中的output子句,以使您可以從修改語句 insert update delete 中將資料返回到表變數中。帶結果的 dml 的有用方案包括清除和存檔 訊息處理應用程式以及其他方案。這一新的 output 子句的語法為 output into table v...

With在sql server 2005中的用法

with在msdn中的講解,可以參考鏈結 1 2 建立錶值變數型別 3 4create type ty newareagoods as table 5 areaid int notnull,6 goodsid int notnull 7 8 9 創鍵返回今天 的資料 10 根據有 的地區獲取參 11...