Sunday, February 19, 2012

Importing a null delimited file

I have a text file that is delimited by nulls. Any idea on the best way to get this into a SQL Server table?You can't delimit with NULLs. Do you mean space characters: " "?|||What do you mean 'null deliminated' file. Technically all files are deliminated by a null character. So I think I misinterpret your meaning.|||Do you mean CHAR(0)?|||"Technically all files are deliminated by a null character."?

...well, I guess you could could say that every text file is delimited by an infinite number of NULL values...|||no, not an infinite number, the sequence stops after the largest prime ;)

actually, i think robert nailed it -- it's probably a hex 00 (also known as a NUL)

see http://www.jimprice.com/jim-asc.htm#controlcodes|||try using \0|||kaiowas, this is sql server, where would you suggest to use that backslash?|||r937, he has a text-file so I figured he's trying to use bcp to get the file into a table.|||Good idea using bcp. I did:

BULK INSERT nullfile FROM 'C:\nullfile.txt'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = '\0',
ROWTERMINATOR = '\n'
)

and it worked :D

No comments:

Post a Comment