SQL Server - Convert text file with ~ delimiter to CSV

Asked By jason barry on 09-Oct-13 07:52 PM
Is there a way to convert a .TXT file using a batch file which will automatically insert the delimiter on rows where there is only some values

for example

a~b~c~dsmith~e~temp~test~ddsds~efedfd~rfff~fdffd~dfdfdf~efefef~ffrfrf~ddcdcd

Lets say the above line is the first record for every file and this will always have the same number of columns

The next line however might look like the following

d~sdsds~sdsds~test1

It only has 4 rows - I would expect it to insert it into the CSV file or another text file like the following

d~sdsds~sdsds~test1~~~~~~~~~~~

Is this possible? I can only achive this using a third party tool to convert the files.

Thankyou