Lets generate this issue step by step.
Step 1 :
First create a table to demonstrate it.
Create table test ( [Employee ID] int identity(1,1), [Employee Name ] varchar (50) ) |
Insert Arabic text (any non-English text) into the table.
Insert into test ([Employee Name ]) values ( 'عمران' ) |
Browse the data from table.
Select * from test --OUTPUT |
Oooops, it became garbage (?????)
Resolution :
Lets resolve it step by step.
Step 1 :
As you can see, the [Employee Name] (Column) has a data type of varchar, so you need to change it to nvarchar data type. Given below is the script to change it.
Alter table dbo.test Alter column [Employee Name ] nvarchar(50) |
Insert the same record again with additional N before name.
Insert into test ([Employee Name ]) values (N 'عمران' ) --OUTPUT |
Step 3 :
Browse the data from table.
Select * from test --OUTPUT |
Conclusion :
Whenever you insert any language (other than English) text into SQL table you must check two things :
- Data type of the field must be nvarchar.
- Insert N before the text.
Source: http://raresql.com/2013/03/14/sql-server-how-to-insert-multilingual-data-in-a-table/
No comments:
Post a Comment