問題描述
我有一個(gè)從另一個(gè)來(lái)源導(dǎo)入的表,作為具有 char 數(shù)據(jù)類型的列,但該字段具有國(guó)際字符.我想在我的表中使用 nvarcvhar.我怎樣才能做到這一點(diǎn)?
I have a table that was imported from another source as a column with the char datatype, but the field has international characters. I would like to use nvarcvhar in my table. How can I achieve this?
我已經(jīng)嘗試更新列(使用alter table 語(yǔ)句或cast as"),但存儲(chǔ)的信息沒有得到轉(zhuǎn)換.
I already tried updating the columns (using an alter table statement, or "cast as") but the info stored did not get converted.
謝謝
推薦答案
您的數(shù)據(jù)目前在 EUC-CN 中,偽裝成 CP1252.它沒有丟失.
Your data is currently in EUC-CN, masquerading as CP1252. It is not lost.
您有多種方法可用于轉(zhuǎn)換為 Unicode(看在轉(zhuǎn)換 SQL 數(shù)據(jù)庫(kù)部分進(jìn)行概述).對(duì)于 SQL Server,您可以 創(chuàng)建擴(kuò)展存儲(chǔ)過(guò)程,用于從 EUC-CN 到 Unicode 的轉(zhuǎn)換.這會(huì)起作用,但并不容易(在這種情況下,您的數(shù)據(jù)使用代碼頁(yè) 51936).
You have several approaches available for conversion to Unicode (look at Converting SQL databases section for overview). In case of SQL Server, you can create extended stored procedures for conversion from EUC-CN to Unicode. This will work but it is not exactly easy (in this case use code page 51936 for your data).
幸運(yùn)的話,根據(jù)您的數(shù)據(jù)中出現(xiàn)的特定字符以及您安裝的語(yǔ)言包,您可能能夠像這樣從代碼頁(yè) 936 進(jìn)行轉(zhuǎn)換:
With some luck, depending on what particular characters occur in your data, and what language packs you have installed, you might be able to convert as if from code page 936 like this:
ALTER DATABASE mydatabasename COLLATE Chinese_PRC
如果成功,請(qǐng)對(duì)要轉(zhuǎn)換的每一列執(zhí)行相同的操作:
If this succeeds, do the same for every column you are going to convert:
ALTER TABLE mytablename ALTER COLUMN mycolumnname
varchar(4000) COLLATE Chinese_PRC NOT NULL
然后才將它們轉(zhuǎn)換為 NVARCHAR.
And only then convert them to NVARCHAR.
這篇關(guān)于將 char 列轉(zhuǎn)換為 nvarchar,以便更改表中已有數(shù)據(jù)的代碼頁(yè)(語(yǔ)言編碼)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!