locked
Strange Question Mart in the Output RRS feed

  • Question

  • User-1284851152 posted

    Hi,

    I wonder why the strange ?????? is appearing in the below query result .  Really don't know about the root cause of this issue. Can someone please shed light on this problem?

    if OBJECT_ID('tempdb..#TB_SPECS') is not null drop table #TB_SPECS
    
    CREATE TABLE #TB_SPECS
    (
      STRING_VALUE NVARCHAR(MAX)
    )
    INSERT #TB_SPECS(STRING_VALUE) 
    VALUES('​​​​​​​SingLe heat-treated and fully thru-hardened for toughness, these guards')	
    
    select * from #TB_SPECS

    Output:- 

    ???????SingLe heat-treated and fully thru-hardened for toughness, these guards

    Monday, February 17, 2020 12:52 PM

Answers

  • User281315223 posted

    Did you copy this value from somewhere? It looks like there are some non-printable characters that are being recognized that correspond to the '?' characters you are seeing:

    You should be fine once you remove those. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 17, 2020 3:09 PM
  • User-719153870 posted

    Hi nagarajasia,

    Really don't know about the root cause of this issue. Can someone please shed light on this problem?

    This is because you are inserting non-unicode string literal into unicode field.  There are some non-unicode characters before "SingLe" as @Rion  mentioned.

    To solved this problem, you can put an "N" before whatever you want to insert:

    if OBJECT_ID('tempdb..#TB_SPECS') is not null drop table #TB_SPECS
    
    CREATE TABLE #TB_SPECS
    (
      STRING_VALUE NVARCHAR(MAX)
    )
    INSERT #TB_SPECS(STRING_VALUE) 
    VALUES(N'​​​​​​​SingLe heat-treated and fully thru-hardened for toughness, these guards')	
    
    select * from #TB_SPECS

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 18, 2020 1:44 AM

All replies

  • User281315223 posted

    Did you copy this value from somewhere? It looks like there are some non-printable characters that are being recognized that correspond to the '?' characters you are seeing:

    You should be fine once you remove those. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 17, 2020 3:09 PM
  • User-719153870 posted

    Hi nagarajasia,

    Really don't know about the root cause of this issue. Can someone please shed light on this problem?

    This is because you are inserting non-unicode string literal into unicode field.  There are some non-unicode characters before "SingLe" as @Rion  mentioned.

    To solved this problem, you can put an "N" before whatever you want to insert:

    if OBJECT_ID('tempdb..#TB_SPECS') is not null drop table #TB_SPECS
    
    CREATE TABLE #TB_SPECS
    (
      STRING_VALUE NVARCHAR(MAX)
    )
    INSERT #TB_SPECS(STRING_VALUE) 
    VALUES(N'​​​​​​​SingLe heat-treated and fully thru-hardened for toughness, these guards')	
    
    select * from #TB_SPECS

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 18, 2020 1:44 AM
  • User-1284851152 posted

    @ Rion Yes I copied the value from an excel sheet.

    Thanks for your reply. I overwhelmed to see you answering my question in Microsoft forums, as I have already read plenty of your articles in the CSharpCorner website (Awesome articles). 

    I must say that something I have learned today. Thanks once again.

    Tuesday, February 18, 2020 8:09 AM
  • User-1284851152 posted

    @Yang Shen

    Thanks for your reply. Your answer has opened doors to learn further for me. Thanks once again.

    Tuesday, February 18, 2020 8:11 AM