Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

coversion error while inserting value in datatype=Int column Expand / Collapse
Author
Message
Posted Tuesday, September 25, 2012 10:46 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, September 17, 2013 2:07 PM
Points: 171, Visits: 556
Hi...I am getting this message
Msg 245, Level 16, State 1, Line 7
Conversion failed when converting the varchar value 'd1867 ' to data type int.

Below is my code:----

INSERT INTO TableA(
ID
)
SELECT
Title
FROM #table


please help.
Post #1364181
Posted Tuesday, September 25, 2012 12:07 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, September 17, 2013 2:07 PM
Points: 171, Visits: 556
I dont want to insert such columns.Please advice.
Post #1364217
Posted Tuesday, September 25, 2012 12:18 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:50 PM
Points: 13,325, Visits: 12,811
komal145 (9/25/2012)
Hi...I am getting this message
Msg 245, Level 16, State 1, Line 7
Conversion failed when converting the varchar value 'd1867 ' to data type int.

Below is my code:----

INSERT INTO TableA(
ID
)
SELECT
Title
FROM #table


please help.


With no details to work with I am going to take a guess that your column ID is an int and you want to insert all rows from #table where Title is a valid int????

INSERT INTO TableA(
ID
)
SELECT
Title
FROM #table
where Title not like '%[^0-9]%'

Jeff Moden wrote a great spackle article about this very recently. http://www.sqlservercentral.com/articles/IsNumeric/71512/


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1364228
Posted Wednesday, September 26, 2012 2:28 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, September 17, 2013 2:07 PM
Points: 171, Visits: 556
Thank you .I filtered the title like isnumeric(title)=1
Post #1364930
Posted Wednesday, September 26, 2012 2:38 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:50 PM
Points: 13,325, Visits: 12,811
komal145 (9/26/2012)
Thank you .I filtered the title like isnumeric(title)=1


If that is what you used it is obvious you didn't read that article very clearly. If this is a one time thing and it worked then that is great. But if you need to repeat this IsNumeric is NOT the way to find values that can't be converted to an int.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1364933
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse