Empty string variable matching to LIKE conditions in SQL

前端 未结 2 1071
误落风尘
误落风尘 2021-01-20 04:17

I have a SQL Server table containing a nvarchar(max) column. I ran a query to select every row where this column contains the string \'remove\'. Amongst the res

相关标签:
2条回答
  • 2021-01-20 04:37

    I think, you should trim the column;

    select itemid, LTRIM(RTRIM(content))
    from objects
    where itemid = 100 and content like '%remove%'
    
    0 讨论(0)
  • 2021-01-20 04:47

    My guess is that you have some control character(s) in the string. If the first character is a newline, for example, that may cause the rest not to be displayed.

    Try

    select item_id, unicode(content) 
    from objects
    where item_id = 100;
    

    This will show the unicode code point for the first character you can see the second character with:

    unicode(substring(item, 2, 1))
    

    and so on.

    0 讨论(0)
提交回复
热议问题