SQL Server: Find out what row caused the TSQL to fail (SSIS)

前端 未结 7 1133
醉话见心
醉话见心 2021-01-13 01:57

SQL Server 2005 Question:

I\'m working on a data conversion project where I\'m taking 80k+ rows and moving them from one table to another. When I run the TSQL, it bo

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 02:16

    What I do is split the rowset in half with a WHERE clause:

    INSERT MyTable(id, datecol) SELECT id, datecol FROM OtherTable WHERE ID BETWEEN 0 AND 40,000
    

    and then keep changing the values on the between part of the where clause. I've done this by hand many times, but it occurs to me that you could automate the splitting with a little .Net code in a loop, trapping exceptions and then narrowing it down to just the row throwing the exception, little by little.

提交回复
热议问题