Import Text file with and Extral Column Delimiter

I ran into a text file (generated from informix(?) ) with an extral pipe (|) appended at the row end. We need to manipulate the importing procees from import/export wizard to skip the last pipe.
You can play with the an extra column from the source and ingnore it from target to do it.
However, I found an easy way :

You can add a pipe (|) directly to Row delimiter (both header and regular Columns) and it should work.

If you are using bcp or bulk insert, you can define both column and row delimiter to import the data to skip the list pipe.
Here is the sample code for bco and bulk insert.


--- Bulk Insert
  BULK INSERT  [TestFullMode].[dbo].[InfoData2]
  FROM 'C:\temp\myDataPipetail.txt'
        ROWTERMINATOR ='|\n',

set @cmd = 'BCP [TestFullMode].[dbo].[InfoData2] IN C:\temp\myDataPipetail.txt -c -T -t\^| -F 2 -r ^|\n -S'+ @@servername
exec master..xp_cmdshell @cmd


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s