Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Inserting multilingual data - loses diacritic marks etc

Inserting multilingual data into a SQL 2008 database (nvarchar field) I notice that it seems to lose some special character marks.

e.g.

    INSERT INTO [dbName].[dbo].[tbl_Question_i18n]  
           ([QuestionId]  
           ,[LanguageId]  
           ,[QuestionText])  
     VALUES  
           (@lastinsertedquestionid  
           ,@romanian  
           ,'Număr unic de referinţă (URN)')  

gets inserted as 'Numar unic de referinta (URN)'

although if I do 'Edit top 200 rows' I can paste the same text directly into that field with no problem.

What am I missing, please?

like image 992
zombiejojo Avatar asked Jul 14 '10 16:07

zombiejojo


1 Answers

INSERT INTO [dbName].[dbo].[tbl_Question_i18n]  
       ([QuestionId]  
       ,[LanguageId]  
       ,[QuestionText])  
 VALUES  
       (@lastinsertedquestionid  
       ,@romanian  
       ,N'Număr unic de referinţă (URN)')

You need the N before the string constant to make it Unicode

like image 180
gbn Avatar answered Nov 15 '22 12:11

gbn