Conversion failed when converting the ****** value '******' to data type ******

前端 未结 4 1774
春和景丽
春和景丽 2021-02-20 05:18

I\'m getting this error from SQL Server on SSMS 17 while running a giant query:

Conversion failed when converting the ****** value \'******\' to data type

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 05:39

    I had the same error when trying to combine an nvarchar and int into a single string. Usually it tells me the data type where I screwed up but occasionally its the error you got.

    I went from

    SELECT ';' + [myNumber]
    

    to

    SELECT ';' + CAST([myNumber] as nvarchar(100))
    

    which solved it for me.

    So as the others have suggested, I guess it is something similar and you need to CAST or CONVERT one of your values to match the rest.

提交回复
热议问题