Search code examples
sqlsql-servert-sqlunicodenvarchar

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?


Solution

  • 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