Monday, 11 June 2012

SQL Server Scripts : Insert Unicode data in SQL Server

Are you having a problem of store Unicode data in database table and it will display  "??????"  ?
Here are solution for that.
SQL Server supports Unicode data in nchar, nvarchar and ntext datatypes.
If you are inserting unicode data as regular data at that time sql does not store unicode characters it store "??????" (Question marks) in also display this "??????".
If you want to store Unicode data you need to specify 'N' ahead of data.

Here are sample example for this.
Let's we have one table "product_master" and we have one column "product_name" and it's data type "nvarchar(500)".
Now we want store one record in that without 'N' .

SQL Query without 'N'
insert into product_master(product_name) values('कंप्यूटर')
select * from product_master

Output :


Now we want store one record in that with 'N' .

SQL Query With 'N'
insert into product_master(product_name) values(N'कंप्यूटर')
select * from product_master

Output :

 

3 comments:

  1. Replies
    1. Thanks for your valuable comments.
      Keep visiting this .Net blog.

      Delete
  2. thanks .... thank you so much

    ReplyDelete