Prefix N and select statement

Answered Prefix N and select statement

  • 2007년 1월 4일 목요일 오후 1:54
     
     

    Dear all,

    I want to convert data to unicode.

    How can I use prefix N  with SELECT statement?

     

    Thanks you!

     

모든 응답

  • 2007년 1월 4일 목요일 오후 2:00
    중재자
     
     

    Lee:

    I am not sure that I am not over-simplyfying my answer, but is this what you are looking for?

    declare @what varchar (40)    set @what = 'This is a test.'

    select cast (@what as nvarchar (20)) as [An Nvarchar?],
           N'This is a test' [A unicode constant]

    -- ------------  Output:  ------------

    --   An Nvarchar?         A unicode constant
    --   -------------------- ------------------
    --   This is a test.      This is a test

    (You just have to be sure to prefix your UNICODE string with an uppercase N and not a lowercase n.)


    Dave


  • 2007년 1월 10일 수요일 오후 3:11
    중재자
     
     답변됨

    Hi,

    If you want to keep unicode data in your database, insert data in a column of type nchar, nvarchar, nvarchar(max) or ntext type.

    Also while inserting the data you can use N'' prefix to issue that the string value within '' is unicode.

     

    If you have your data currently stored in char, varchar or text type columns, some characters may have lost their initial values. You can not convert them back to original values. This is same if you had inserted values without using the N'' prefix.

    Eralper

    http://www.kodyaz.com