开发者

How to INSERT EXEC when the result data from a CLR SP should be truncated?

I'm inserting the result set returned from a CLR stored procedure into a table variable. I get the error: "System.Data.SqlClient.SqlException: String or binary data would be t开发者_开发百科runcated", because some strings' lengths in the result set exceed the varchar limit defined in the temporary table. The annoying thing is, truncation is exactly what I want!

So, how do I truncate (the strings in) the result set from the stored procedure, upon inserting it?

I'd rather not change the code of the CLR SP. The strings in the data that's being inserted are of arbitrary length.


I think I'd make the columns of the temp table large enough to accept the data, then truncate after the insert, e.g.,

UPDATE #YourTempTable
    SET ColumnA = LEFT(ColumnA, 20),
        ColumnB = LEFT(ColumnB, 50)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜