How To Save Unicode Data in SQL server

  • how to implement Unicode ...In a Database i m having a field with nvarchar (max) datatype when inserting a unicode string from the text box in to the database ...it is saving ???????????? in the database .

  • did u use N'your unicode data' when inserting?

  • SQL Server supports Unicode data for the data types nchar, nvarchar & ntext, so you might be missing something in the front end application or in the procedure...

    --Ramesh


  • I did that but still it is saved in the database as a ??????....

    Can you Please tell me Where to use that "N" ...I m putting that into when executing the procedure to insert the unicode characters .

    This is wt i m doing .

    I have a Text box and a button ..

    I put unocde string (set of Unicode characters ) in that text box

    getting the unicode input from the text box .

    In the database i hav a a table with one colom with nvachar(max) datatype .

    it is saving the record in the database but as a ?????????

    when i put N before that then it will look like N ?????????????

  • In your app, let say, you do somethin like this

    dim str_data

    str_data = "a unicode string"

    'call stored procedure

    ...

    connection.execute "exec sp_insertSomething N'" & str_data & "'"

    ---------------------

    In you sp,

    create proc sp_insertSomething @param nvarchar(max) as

    insert into mytable (col1) values (@param)

    ---------------------

    to test this, you can run

    exec sp_insertSomething N'a unicode string'

    directly in management studio. when you select data from the table, you should not see ???????.

    IF you still get ?????? in management studio, that means your character code is not supported by Microsoft.

    SQL Server only supports UCS-2 and UCS-4.

    anyway, when you pass the string back to your app, you can still convert it back to the charset that you want.

    you can try it out. 😉

  • Bingo !!!!!!!!!

    Yes it is Working and Working Fine with No Errors !!

    Thank You So much ...But still I have a confusion in my mind that whether we are working 100% with Unicode based Encoding or not .

    Thank You So much and Still I required a guidance if any other is there .

  • Hello Dear Frens .....the unicode solution working fine with VS 2005 but when i m implementing this with VS 2003 it is having some problem

    it is inserting N in the database with the unicode string.

    this is my one of the parameter

    insParams(0) = New SqlParameter("@NewsTitle", "N'& newstitle & '")

    but when it is executing it is saving with N like this

    N '????? ????? ?? ????????? ??? ???????? ??' and at the time of retreiving it is showing the N

    Please help me

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply