How to skip the invalid rows while inserting the data into Database
Posted
by Dinesh
on Stack Overflow
See other posts from Stack Overflow
or by Dinesh
Published on 2010-05-11T04:19:50Z
Indexed on
2010/05/11
4:24 UTC
Read the original article
Hit count: 224
We have a statement., that is inserting some rows in a temporary table (say e.g., 10 rows), while inserting 5th row, it has some issue with one of the column format and giving an error and then it stopped inserting the rows. What I want is, it should skip the error rows and insert valid rows. For those error rows, it can skip that error column and insert with some null value & different status.
create table #tb_pagecontent_value (pageid int,formid uniqueidentifier, id_field xml,fieldvalue xml,label_final xml)
…
…
insert into #tb_pagecontent_xml
select A.pageid,B.formid,A.PageData.query('/CPageDataXML/control')
from Pagedata A inner join page B on A.PageId=B.PageId
inner join FormAssociation C on B.FormId=C.FormId
where B.pageid in (select pageId from jobs where jobtype='zba' and StatusFlag!=1)
in the above e.g., I want to apply that logic. Any help is appreciated.
© Stack Overflow or respective owner