SQL Server - Multi language data support - The Koch Family
The Koch Family The Koch Family

Latest news

جاري التحميل ...

SQL Server - Multi language data support


I used CKEditor to edit my pages. Then, I stored the content of the pages to SQL Server 2008 database. The page contents should support in different languages such as English, German and Vietnamese. I met a problem when I worked on Vietnamese pages.
The text was successfully saved but it was displayed wrong when reading again from database, likes the following:
Input: "Ðây là Tiếng Việt"
Display: "Ðây là Ti?ng Vi?t".


We need to use nvarchar (nchar | ntext) data type for strings  and we also need to precede all unicode strings with 'N'

Here is my code:
--create table
CREATE TABLE [dbo].[xedu_page_content](
[id] [numeric](11, 0) IDENTITY(1,1) NOT NULL,
[category] [varchar](100) NOT NULL PRIMARY KEY,
[content] [Ntext] NULL

IF not exists (SELECT category FROM xedu_page_content
WHERE category='"+in.categoryKey+"')
INSERT INTO xedu_page_content(category,content)
VALUES ('"+in.categoryKey+"',N'"+in.content+"');
UPDATE xedu_page_content
SET content = N'"+in.content+"'
WHERE category='"+in.categoryKey+"'

[1]. http://stackoverflow.com/questions/2017198/sql-server-multi-language-data-support
[2]. http://msdn.microsoft.com/en-us/library/ms186939.aspx


If you like the content of our blog, we hope to stay in constant communication, just enter your email to subscribe to the blog's express mail to receive new blog updates, and you can send a message by clicking on the button next ...

إتصل بنا

About the site

author The Koch Family <<  Welcome! I'm so glad that you stopped by Your Modern Family blog. Together, we will talk about raising kids, organizing the home and saving money! and Tips & tricks and more…

< Learn more ←

Blog stats

Sparkline 2513183

All Copyrights Reserved

The Koch Family