defining text delimiter for a csv file to import in SQL Server

1.3k views Asked by At

I am having some trouble importing a csv file into a SQLServer Database. I am hoping there is a way around my problem.

Source file:

  • Text file with | delmited around all fields
  • Each row is sepparate with a tabstopp (new row begins also in a new line)

Below is a sample line of the csv file

FROM @classes AS c
CROSS APPLY (
SELECT TOP (@0) _entry_id, _guid, _sid, _path, _display_name, _name, _description, _account_name, _group_type, _is_admin, _user_account_control 
FROM ad._active_directory_entries_418 AS e WHERE _class_id = c._class_id AND (_path LIKE N'%DC=octo,DC=local' COLLATE Latin1_General_CI_AS OR _path LIKE N'%DC=testdom,DC=local' COLLATE Latin1_General_CI_AS OR _path LIKE N'%DC=protected-networks,DC=local' COLLATE Latin1_General_CI_AS)
AND (( PATINDEX(@searchParam0, COALESCE(e._name, '') COLLATE Latin1_General_CI_AI) <> 0  OR  PATINDEX(@searchParam0, COALESCE(e._display_name, '') COLLATE Latin1_General_CI_AI) <> 0  OR  PATINDEX(@searchParam0, COALESCE(e._account_name, '') COLLATE Latin1_General_CI_AI) <> 0 ) OR _entry_id IN (SELECT _entry_id FROM @entries))
) AS e 
OUTER APPLY (
SELECT * FROM
(SELECT _value, n FROM ad._active_directory_entry_properties_418 AS p 
INNER JOIN @propertiesToRead AS ptr ON ptr.id = _name_id
WHERE _property_id IN (SELECT _property_id FROM ad._active_directory_entry_property_mapping_418 WHERE _entry_id = e._entry_id)
) AS rawData
PIVOT
( MAX(_value)
FOR n IN (empty_property_list)
) AS pivottable
) AS details|NULL|1|1|2015-04-15 11:14:15.390|2015-04-15 11:14:15.420|1115,817|0,01859695|1115817|1115817|1115817|1115817|1107748|1107748|1107748|1107748|0|0|0|0|10051|10051|10051|10051|0|0|0|0|64|64|64|64|NULL|0x012F58F0645D8208|0xBEBA0EA95676B128|0x020000009CCDCE043C12EDAAE7A333C71AF128A51FB154790000000000000000000000000000000000000000|0x060016009CCDCE04B0DC38240400000001000000000000000000000000000000000000000000000000000000|<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.2" Build="12.0.2000.8"><BatchSequence><Batch><Statements><StmtSimple StatementText="(@0 int,@1 varchar(200),@searchParam0 nvarchar(4000))SET ARITHABORT ON; " StatementId="1" StatementCompId="1" StatementType="SET ON/OFF" RetrievedFromCache="true" /><StmtSimpleStatementText="DECLARE @propertiesToRea......... 

Problem

All columns are recognized except the last one, which begins with </ShowPlanXML...

enter image description here

I am defining rowdelimiter and column delimiter like this figure:

enter image description here

I am using such a mic delimitor for each row Tabstopp {t}{CR}{LF} but it doesnt work too

0

There are 0 answers