Is there a way to ignore "Message 8152 16 String or binary data would be truncated." so that the Update or Insert is successful even though string value is being truncated.
You get that error when you try to insert too much data in to a field that cannot hold that much.
Code:
declare @Temp Table(Data varchar(2))
[green]-- This one errors[/green]
Insert Into @Temp Values('This is too long.')
[green]-- This one is fine[/green]
Insert Into @Temp Values([!]Left([/!]'This is too long.'[!], 2)[/!])
-George
Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
I was hoping that I do not have to code each column with Left(). Is there a way to disable so it automatically takes only the part of the string that fits in the column width.
>>I was hoping that I do not have to code each column with Left(). Is there a way to disable so it automatically takes only the part of the string that fits in the column width.
restrict on the input side and use stored procedures with parameters that are the same size as the columns
create table blah (a varchar(1))
insert blah select 'ab'
select * from blah
set ansi_warnings off
insert blah select 'ab'
select * from blah
set ansi_warnings on
drop table blah
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.