BigBlackDog
BigBlackDog

Reputation: 544

UTF-8 character gets changed in INSERT statement on MS-SQL-Server

I have a table on my MS-SQL-Server 2008R2 that itself has an nvarchar(50) field.

Now when i insert a value using the Server Management Studio like

INSERT INTO INFORMATIONS(SOME_TEXT) VALUES('finančné služby')

and i immediately select the value

SELECT SOME_TEXT FROM INFORMATIONS

i get

financné služby

So the čdoes get converted into a plain c while the ž is handled just fine.

What am I missing here?

The collation is set to Latin1_General_CI_AS if that is of any help.

Upvotes: 14

Views: 30355

Answers (3)

lava
lava

Reputation: 7373

Add N with the with string

  insert into Item_Registration ([fırstlan_arabic],[second_turkish])values(N'قهوة شوكو',N'قهوة شوكو')

enter image description here

ıf you are usıng C# or vb.net and Sqlcommand for inserting utf character you can use SqlDbtype.NText data type

CMD = New SqlCommand(cb)
 CMD.Parameters.AddWithValue("@d11", SqlDbType.NText).Value =
                    If(txt_name_secondlan.Text = "", "''", txt_name_secondlan.Text)

Upvotes: 0

Vrunda Savaliya
Vrunda Savaliya

Reputation: 180

If you are working with stored procedure then give type 'Nvarchar' instead of Varchar of that particular filed on that you will store UTF-8 characters

Upvotes: 1

Mudassir Hasan
Mudassir Hasan

Reputation: 28741

Prefix your values with N while inserting.

INSERT INTO INFORMATIONS(SOME_TEXT) VALUES(N'finančné služby')

CHECK SQL FIDDLE DEMO

Upvotes: 33

Related Questions