September 24, 2009 at 8:37 pm
Dear All,
I have problem with dat file which I have to import it into database by code below:
the problem is: if there is a line which don't have close tag " the importing get error and any line is not import.
so,how can I import the lines which are corrected I mean the line which has "
Please help.
/*my example dat file */
/*end my dat file*/
/*my import code */
DECLARE @xml XML
SELECT @xml = BulkColumn
FROM OPENROWSET
(
BULK '\\ServerName\Sharefolder\FileName.Dat', SINGLE_BLOB
) X
INSERT INTO dbo.TestLog (Code,Time,Target,Machine,Elapsed)
SELECT
C.value('@code', 'varchar(50)') as [Code],
C.value('@time', 'datetime') as [Time],
C.value('@target', 'varchar(max)') as [Target],
C.value('@machine', 'varchar(50)') as [Machine],
C.value('@elapsed', 'varchar(50)') as [Elapsed]
FROM @xml.nodes('/Msg') X(C)
/* end my code */
September 25, 2009 at 1:51 am
Can you add to your process a step which checks that the input XML is well formed?
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply