Conversion failed when converting the varchar value '%' to data type int

后端 未结 1 1852
孤独总比滥情好
孤独总比滥情好 2021-01-25 04:20

I created a procedure and got this message

Conversion failed when converting the varchar value \'%\' to data type int.

create p         


        
相关标签:
1条回答
  • 2021-01-25 04:46

    This is in the where clause:

    YEAR like '%'+@year+'%' and
    

    @year is an integer. So, you need to convert it to a string:

    YEAR like '%'+ cast(@year as varchar(255)) + '%' and
    

    Why you are using like for a column called YEAR is suspicious. Perhaps you just want:

    (YEAR = @year or @year IS NULL) and
    
    0 讨论(0)
提交回复
热议问题