Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IGNORE : 8152 16 String or binary data would be truncated. ? 1

Status
Not open for further replies.

myvision69

Programmer
Feb 3, 2006
18
US
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
 
Thanks for the quick response.

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

Denis The SQL Menace
SQL blog:
Personal Blog:
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top