May 14, 2008 at 2:08 pm
is there a way to ignore the truncate error and force the insert to finish.
For example,
Table_A has some columns whose length is longer than the ones in Table_B
Is there way to make the following SQL to work?
INSERT INTO Table_B
Select * FROM Table_A
Thanks
May 30, 2008 at 2:35 am
Yes, explicitly cast (or convert) the source values to the destination data type. Never rely on implicit conversions, better yet avoid them like the plague. SQL Server is not as good at guessing as you might have expected, so don't let it.
And just in case your next question is about too many column names to type, in SSMS you can drag the column names from the Object Browser pane.
ML
---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com
May 30, 2008 at 2:45 am
bull2000 (5/14/2008)
is there a way to ignore the truncate error and force the insert to finish.For example,
Table_A has some columns whose length is longer than the ones in Table_B
Is there way to make the following SQL to work?
INSERT INTO Table_B
Select * FROM Table_A
Thanks
Setting ansi_warnings to off will ignore the truincate error. You are better off explicitly casting/truncating yourself though.
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537May 30, 2008 at 3:49 am
Mark (5/30/2008)
Setting ansi_warnings to off will ignore the truncate error. You are better off explicitly casting/truncating yourself though.
Are you sure about that, Mark? Well, I wouldn't want to truncate myself :w00t: not even if it is painless. I'll probably stick to truncating the data 😛
(Sorry, I couldn't resist that... otherwise, of course, I agree that explicit truncation is the right way).
May 30, 2008 at 3:52 am
Trunkating people is the domain of the Sopranos.
😉
ML
---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply