title: T-SQL finding out which row causes the error
body: <p>I have a stored procedure that inserts thousands of rows and if there is bad data in any of the rows, it fails. I do the inserts inside a while loop and it would be nice if there is a way I can have it spit out the row at which the stored procedure is failing. The query and the loop is as such:</p>
  
  <pre><code>WHILE @rownum &gt; 1
  BEGIN
      INSERT INTO dbo.bestsellers (id, name, datastring, country)
      VALUES (@id, @name, @datastring, @country)
  END
  </code></pre>
  
  <p>Is there a way to have it spit it out the @id, @name, @datastring, @country data at which it is failing due to bad data?</p>