1

I have a file saved as Unicode text containing Ukrainian characters, and it got loaded successfully to staging table using SSIS.

Like this:

"Колодки тормозные дисковые, комплект"
Колодки тормозные
"Колодки тормозные дисковые, комплект"
This is Test

But when I am moving it to other table it changes to:

"??????? ????????? ????????, ????????"
??????? ?????????
"??????? ????????? ????????, ????????"
This is Test

The query I used:

insert into finaltable
(
column1
)

select column1 from staging table.

Collation: Latin1_General_CI_AS

How can I rectify this error?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rohini Mathur
  • 431
  • 1
  • 5
  • 19

2 Answers2

4

Here you can see the deference between VARCHAR and NVARCHAR datatypes:

DECLARE @Non_Unicode_Var VARCHAR (MAX) = 'Колодки тормозные дисковые, комплект';
DECLARE @Unicode_Var NVARCHAR (MAX) = N'Колодки тормозные дисковые, комплект';

SELECT @Non_Unicode_Var AS NonUnicodeColumn, @Unicode_Var AS UnicodeColumn;

Result:

+--------------------------------------+--------------------------------------+
|           NonUnicodeColumn           |            UnicodeColumn             |
+--------------------------------------+--------------------------------------+
| ??????? ????????? ????????, ???????? | Колодки тормозные дисковые, комплект |
+--------------------------------------+--------------------------------------+

So, you need to change the data type to NVARCHAR data type, then insert your data into the table.

Ilyes
  • 14,640
  • 4
  • 29
  • 55
2

Use nvarchar in your table and when you type your strings in the insert statement put N in front, like N'your string'. Also consider changing your collation due to sorting issues, refer to this question.

PacoDePaco
  • 689
  • 5
  • 16
  • i did like this . N'[DESC]', but it is inserting DESC in column. – Rohini Mathur Sep 13 '17 at 11:23
  • @RohiniMathur Yeah , it's like that – Ilyes Sep 13 '17 at 11:25
  • i have changed data type to nvarchar and N'DESC' but instead of column value, it is inserting string 'DESC'. Please suggest. – Rohini Mathur Sep 13 '17 at 11:42
  • if you specify a string in your insert statement, you will get this string inserted. You should use N'string' only when you insert new values into the table. After you changed datatype to nvarchar you should try to execute your original query which selects values from the staging table – PacoDePaco Sep 13 '17 at 11:47