Tuesday, June 9, 2020

SQL SERVER : Store and Retrieve different languages data from Table

Here in this article I am going to explain how we can store and retrieve the different languages (other than English) data from SQL SERVER table.

 

When working on an application get requirement to store the data of other language than English (multilingual) in database. If you have get any such requirement, you can achieve this following two things:

Set Unicode compatible datatype (ntext, nvarchar, nchar) for table column

Use N (capital) as a prefix before inserting data/text

 

Example :

First of all, create a table. I have created table to store admin users name.



Create table tblAdmin (
EnglishName NVARCHAR(100),
HindiName nchar(100),
JapaneseName ntext
)

 

Now insert data into table.

insert into
tblAdmin(EnglishName,HindiName,JapaneseName) values(N'Vijay Saklani', N'विजय सकलानी',N'ビジェイ・サクラニ')

Get the data from table and check the saved data.

Select * from tblAdmin

 

SQL SERVER : Store and Retrieve different languages  data from Table

If you will insert the into table without prefix N, data will not be useful. It will be inserted in question mark (????) form and become garbage. Let’s check with this also:

insert into tblAdmin(EnglishName,HindiName,JapaneseName) values('Vijay Saklani',
'विजय सकलानी','ビジェイ・サクラニ')

 

Check the inserted data now.

 SQL SERVER : Store and Retrieve different languages  data from Table



No comments:

Post a Comment