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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data would be truncated error

Status
Not open for further replies.

judyscofield

Programmer
Sep 24, 2001
56
US
I'm getting a 'String or Binary Data Would be Truncated' error when running my code. I have an .addnew command, then fill some fields, and then an .update command. I've tried putting values into the fields that I know are smaller than the field lengths.

Other posts have advised to add SET ANSI_WARNINGS OFF. I added that line to my code and get a compile syntax error on that line. Can anyone help?
 
Can you post the code?

do you still want to insert values into the fields, knowing that the value inserted exceeds the field length?

if you are using VB, then it has be set at the Connection level example cn.excute("SET ANSI_WARNINGS OFF")

Example
create table #temp(Yourname char(10))

--This Works
SET SET ANSI_WARNINGS OFF
insert into #temp values('12345678901')
SET SET ANSI_WARNINGS ON

--This Fails (The default setting in SQL Server)
SET SET ANSI_WARNINGS ON
insert into #temp values('12345678901')
SET SET ANSI_WARNINGS OFF

SELECT * FROM #temp
go
drop table #temp




dbtech



 
No I really don't want to post anything that's too long. After further investigation, I discovered that a default value was causing the error, not any of the strings I was trying to insert. Thanks for your help. Judy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top