November 30, 2010 at 10:39 am
Here is the scenario. I've got a field which is varchar(50) and when I try to insert something larger than 50 characters I get back an error, obviously. Here's my question: Is there a way to suppress this error and have the field auto-truncate to 50 characters on the call to insert? I only want to suppress the error on this particular column.
Don
November 30, 2010 at 10:41 am
Are you inserting via T-SQL, SSIS, or some other means?
In T-SQL, you can use Left() in your Select to cut it off at 50 characters.
In SSIS, you'd use a derived column and do the same thing.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 30, 2010 at 10:51 am
What I'm actually doing is raising the limit to 500 and then using left() on my insert in T-SQL to have it function correctly. Having done that is what made me curious about single-column T-SQL error suppression.
Don
November 30, 2010 at 10:53 am
Nope. Would violate basic database ACIDity, because the transaction wouldn't be atomic.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 30, 2010 at 10:57 am
Absolutely. Always makes me curious though since we're often given lots of rope and different types of rope with which to hang ourselves.. lol
Thanks folks.
Don
November 30, 2010 at 10:58 am
You're welcome.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply