SQLException : String or binary data would be truncated

前端 未结 12 969
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 06:41

I have a C# code which does lot of insert statements in a batch. While executing these statements, I got \"String or binary data would be truncated\" error and transaction r

12条回答
  •  甜味超标
    2020-11-27 07:18

    BEGIN TRY
        INSERT INTO YourTable (col1, col2) VALUES (@val1, @val2)
    END TRY
    BEGIN CATCH
        --print or insert into error log or return param or etc...
        PRINT '@val1='+ISNULL(CONVERT(varchar,@val1),'')
        PRINT '@val2='+ISNULL(CONVERT(varchar,@val2),'')
    END CATCH
    

提交回复
热议问题