Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2002
    Posts
    58

    Unanswered: 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?

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You can't delimit with NULLs. Do you mean space characters: " "?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    9
    What do you mean 'null deliminated' file. Technically all files are deliminated by a null character. So I think I misinterpret your meaning.

  4. #4
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Do you mean CHAR(0)?
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    "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...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Feb 2004
    Posts
    492
    try using \0

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    kaiowas, this is sql server, where would you suggest to use that backslash?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Feb 2004
    Posts
    492
    r937, he has a text-file so I figured he's trying to use bcp to get the file into a table.

  10. #10
    Join Date
    Feb 2002
    Posts
    58
    Good idea using bcp. I did:

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

    and it worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •