1

Ive got text file with utf-8 encoding with more then 2k lines of insert command. Now I would like to execute it as a sql script to insert data into database.

There is greek text with which there are problems. After inserting there are only ? characters, no greek letters.

sample insert statement is presented below:

INSERT INTO myDB.[MC_LIST] 
    ([id], [data], [author], [created], [language], [type_name], [position]) 
 VALUES 
    ('2086','<data><id>1</id><language>gr</language><szonelinkdest>/products/how-does-nioxin-works-page.aspx</szonelinkdest><szoneimgalt>alt</szoneimgalt><title>ΠΡΟΣΕΓΓΙΣΗ ΦΡΟΝΤΙΔΑΣ ΤΗΣ ΕΠΙΔΕΡΜΙΔΑΣ</title><szoneimg>/m/photo/box-4.jpg</szoneimg><szonedesc>Κάθε προϊόν lala περιέχει έναν εξειδικευμένο συνδυασμό συστατικών επιστημονικής προέλευσης. </szonedesc><szonelinkname>ΟΙ ΤΕΧΝΟΛΟΓΙΕΣ ΜΑΣ</szonelinkname><szonetitle>ΠΡΟΣΕΓΓΙΣΗ ΦΡΟΝΤΙΔΑΣ ΤΗΣ ΕΠΙΔΕΡΜΙΔΑΣ</szonetitle></data>',null,'4/15/2011 3:47:47 PM','gr','1','2') ;

What to do to make it work ?

thanks for any help.

Btw do You know any software which can convert utf-8 file to utf-16 file ?

gruber
  • 28,739
  • 35
  • 124
  • 216
  • How is this different from your earlier question, [greek language in xml column sql server 2005](http://stackoverflow.com/questions/7373224/greek-language-in-xml-column-sql-server-2005)? – Michael Petrotta Sep 10 '11 at 18:24
  • there are a lot of differences – gruber Sep 10 '11 at 18:42
  • You pull data out, Greek characters. Insert data, no Greek characters. Looks like the same problem to me. It's better form on SO to edit your original question with clarifications, as opposed to creating an entirely new question. – Michael Petrotta Sep 10 '11 at 18:43

1 Answers1

8

First, your destination columns need to be able to store unicode data. These are nvarchar(), ntext, nchar.

Second, try prefixing the string containing cyrillic characters with N for unicode.

Ie: INSERT INTO table(columnname) VALUES(N'yourstring')

Hope that helps.

MegS
  • 96
  • 1
  • Correct on the `N` prefix for the string literal. There is no requirement for the column to be of an `Nxyz` type however `varchar` etc. will also work as long as the column collation is suitable. – Martin Smith Sep 10 '11 at 19:46
  • Or the column can be xml datatype. – gbn Sep 11 '11 at 08:54
  • the only one correct comment.answer. Thank You very much hor help – gruber Sep 12 '11 at 13:34