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

前端 未结 2 1228
失恋的感觉
失恋的感觉 2021-01-05 11:52

I got this error when trying run my sql query...

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

2条回答
  •  无人及你
    2021-01-05 12:10

    In your Join condition am sure one column is of Integer type and other one is Varchar type.

    ON History.Id = Header.docId
    

    since Int has higher precedence than varchar, Varchar column will be implicitly converted to Int

    So explicitly convert the Int column to varchar.

    ON History.Id = cast(Header.docId as varchar(50))
    

    I have considered Header.docId as Int type if no, then convert History.Id to varchar

提交回复
热议问题