how to fetch records which throws error?

  • Hi There,

    how to fetch records which throws error?

    For example

    I'm inserting records from a table to another table, having multiple columns

    SampleQuery :

    insert into tableB (col1,col2....col10)

    select col1,col2....col10 from tableA

    * while executing this query im getting error. (like varchar cant convert to numberic)

    * Here I have no clue in which column it is

    * also dont know which row causes it

    How to fix this?

  • Some days, it helps if you think before typing...

    you could do it in batches and use a TRY CATCH block for the failure, and write the failed group of records to another table...

  • pietlinden (2/27/2015)


    Some days, it helps if you think before typing...

    you could do it in batches and use a TRY CATCH block for the failure, and write the failed group of records to another table...

    Im currently doing that. But I wonder is there any features in sql to do so.

  • * while executing this query im getting error. (like varchar cant convert to numberic)

    * Here I have no clue in which column it is

    * also dont know which row causes it

    That error message gives you a strong clue: your source column is varchar() and your destination is numeric(). Start checking datatypes and make sure that they match – or that you explicitly handle the conversions in your source query.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply