September 25, 2012 at 10:46 am
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.
September 25, 2012 at 12:07 pm
I dont want to insert such columns.Please advice.
September 25, 2012 at 12:18 pm
komal145 (9/25/2012)
Hi...I am getting this messageMsg 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/[/url]
_______________________________________________________________
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 26, 2012 at 2:28 pm
Thank you .I filtered the title like isnumeric(title)=1
September 26, 2012 at 2:38 pm
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply