To store data of other language than English in SQL Server, we use Unicode compatible data types in the column such as nvarchar, nchar, ntext otherwise proper data is not stored in the database. Also while inserting data into those columns we prefix the data with “N” character.
In order to demonstrate this, we have created a sample demo database table named LanguageTest
Where the LangData and LangDataN columns will be used to store data.
LangData is of varchar type and LangDataN is of nvarchar type (Unicode compatible)
We have entered three records into this table with the help of below INSERT statements. Write below query in the Query window and click on “! Execute” icon at the top-left.
Note that in the above insert statements, the second statement is inserting data into LangDataN column that is of nvarchar type and third statement is also inserting data into LangDataN column but by prefixing “N”.
Now, the result looks like below.
When we inserted data into LangDataN column without prefixing “N”, the data appears as”????.....” but when we insert data by prefixing “N” in the LangDataN, it insert correct data in correct format.
Remember that if we are inserting data into LangDataN column using .NET program, we do not need to prefix the data with “N”. Like in below example.
Views: 6231 | Post Order: 28