Skip to content
Related Articles

Related Articles

Improve Article

Storing a Non-English String in Table – Unicode Strings in SQL SERVER

  • Last Updated : 22 Mar, 2021

In this article, we will discuss the overview of Storing a Non-English String in Table, Unicode Strings in SQL SERVER with the help of an example in which will see how you can store the values in different languages and then finally will conclude the conclusion as follows.

Introduction : 
SQL Server Uses English as the default language for the database and someone wants to use other languages (e.g. Hindi, Gujarati, etc.)  Words in the SQL Server table. Whenever we need to use another language SQL Server, we must use the data type NVARCHAR for the column. If we don’t use the datatype NVARCHAR, we will be not able to store non-English values.

Example : 
In this example, you will see how you can store the values in the different languages in the database. So first, we will create a table as follows.

Creating a table -TestLang –
Let us create a table named ‘TestLang’.

  LangName VARCHAR(100),
  Value VARCHAR(1000),
  NValue NVARCHAR(1000)

Inserting data –
Now, insert data of different languages in the table as follows.

INSERT INTO TestLang (LangName, Value, NValue)
VALUES ('English', 'Welcome to GFG', N'Welcome to GFG');

INSERT INTO TestLang (LangName, Value, NValue)
VALUES ('Gujarati', 'GFG માં આપનું સ્વાગત છે', N'GFG માં આપનું સ્વાગત છે');

INSERT INTO TestLang (LangName, Value, NValue)
VALUES ('Hindi', 'GFG में आपका स्वागत है', N'GFG में आपका स्वागत है');


Verifying data –
Selecting data from the table as follows.

FROM TestLang

Output :

EnglishWelcome to GFGWelcome to GFG
GujaratiGFG ??? ????? ?????? ??GFG માં આપનું સ્વાગત છે
HindiGFG ??? ???? ?????? ??GFG में आपका स्वागत है

SQL Server Management Studio output :
You can see the given below screenshot to see the output from SQL Server Management Studio as follows.

Conclusion :  
From the above output, we could observe that when we have Unicode datatype we are able to store the non-English string. The recommendation to use NVARCHAR is when the sizes of the data in column entries vary considerably and the string length may be greater than 4,000 byte-pairs.

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

My Personal Notes arrow_drop_up
Recommended Articles
Page :