Solved

SET ANSI_WARNINGS OFF

Posted on 2006-06-22
5
1,069 Views
Last Modified: 2012-05-05
I keep getting this error.

String or binary data would be truncated

I've done numerous checks to make sure the fields are large enough for the data, and they are.  Somethings just not working.  I don't care if the data is truncated.  I read a post aobut using the SET ANSI_WARNINGS OFF but I can't seem to get that to work.  I am using ASP.NET with an SqlDataAdapter to add 55,000 rows to a newly created table from a "|" delimited text file.  

I use EMS SQL manager, and I tried executing a script on the database:

SET ANSI_WARNINGS OFF
GO

and I still get the "...would be truncated error"

How do I set it so that it truncates it? I have 75 columns so there has to be an easier way then going through and truncating each objRow("fieldName") = myData(0) within the code.

Please help,

thanks

Chris
0
Comment
Question by:seefresh
  • 2
  • 2
5 Comments
 
LVL 25

Expert Comment

by:jrb1
ID: 16961688
Are you running a stored procedure?  Is that command in your SP?
0
 

Author Comment

by:seefresh
ID: 16961732
No its not, I'm not too sure about stored procedures.  You put a stored procedure on a specific table right? Would I have to make a "truncate" type command for each field if I used a stored procedure?
0
 
LVL 25

Accepted Solution

by:
jrb1 earned 500 total points
ID: 16962413
I don't think so.  I believe that if you were using a stored procedure, and the stored procedure first did the "SET ANSI_WARNINGS OFF", you wouldn't get the error returned.
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 16963587
this more probably indicates thta you have a malformed row in the input....
have you confirmed that the data is being processed correctly and that all rows have 75 columns presented..

which database system are we dealing with...?
0
 

Author Comment

by:seefresh
ID: 16964253
mssql database, yes, if a row doesn't have 75 columns I skip it.  I check after I split the row:

newRow = Split(currentLine, "|")
If newRow.Length = 75 Then

 ...add to db

End If

Do I need to re-write my entire data input to work with a stored procedure?
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question