locked
Special Characters('⅜') displayed as Question Mark (?) in SQL RRS feed

  • Question

  • User-1284851152 posted

    Dear Members,

    I have come across a strange issue with SQL Server 2014 i.e., If i run the below query the special chararcter ('⅜') got replaced by Question Mark ('?')

    SQL Query:

    Declare @ProductName varchar(100)= N'Washton ⅜ ¼ ' 
    select @ProductName

    Output:

    Washton ? ¼ 

    I am unable to figure out the cause of the issue / solution for it. Could anyone shed some light on the above issue?

    Monday, November 11, 2019 6:45 AM

Answers

  • User-2082239438 posted

    Use Data type NVARCHAR (Support of UniCode to display non-ascii char).

    Declare @ProductName Nvarchar(100)=N'Washton ⅜ ¼ ' 
    select @ProductName
    
    
    -----
    Washton ⅜ ¼ 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 11, 2019 7:25 AM
  • User-719153870 posted

    Hi nagarajasia,

    I am unable to figure out the cause of the issue / solution for it.

    You declared a varchar type parameter and set it unicode characters which will be stored as Washton ? ¼ automatically.

    Thus, the only solution here is to change the type of parameter to nvarhcar which can store any Unicode data just like @yrb.yogi posted.

    For more information, please refer to What is the difference between varchar and nvarchar? and below demo:

    Notice, use N'' to make it as unicode, please refer to What is the meaning of the prefix N in T-SQL statements?

    create table #t
    (name varchar(100))
    insert into #t values('Washton ⅜ ¼')
    insert into #t values(N'Washton ⅜ ¼')
    
    alter table #t alter column name nvarchar(100)
    insert into #t values('Washton ⅜ ¼')
    insert into #t values(N'Washton ⅜ ¼')
    
    select * from #t

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 11, 2019 8:21 AM

All replies

  • User-2082239438 posted

    Use Data type NVARCHAR (Support of UniCode to display non-ascii char).

    Declare @ProductName Nvarchar(100)=N'Washton ⅜ ¼ ' 
    select @ProductName
    
    
    -----
    Washton ⅜ ¼ 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 11, 2019 7:25 AM
  • User-719153870 posted

    Hi nagarajasia,

    I am unable to figure out the cause of the issue / solution for it.

    You declared a varchar type parameter and set it unicode characters which will be stored as Washton ? ¼ automatically.

    Thus, the only solution here is to change the type of parameter to nvarhcar which can store any Unicode data just like @yrb.yogi posted.

    For more information, please refer to What is the difference between varchar and nvarchar? and below demo:

    Notice, use N'' to make it as unicode, please refer to What is the meaning of the prefix N in T-SQL statements?

    create table #t
    (name varchar(100))
    insert into #t values('Washton ⅜ ¼')
    insert into #t values(N'Washton ⅜ ¼')
    
    alter table #t alter column name nvarchar(100)
    insert into #t values('Washton ⅜ ¼')
    insert into #t values(N'Washton ⅜ ¼')
    
    select * from #t

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 11, 2019 8:21 AM