With reference to Import and Export Wizard, in SQL Server 2005 environment, I would like to receive some suggestions on how to select the best field separator: the table I need to export as flat file for example contains columns with commas inside them, so I can’t use comma as field separator.
I have thought to search in all tables what is the ASCII character (0-255) NOT PRESENT, and use this character as separator, but this search operation is computationally heavy.
- What type of character could I use for exporting a table as flat file?
- Could I use a couple of characters, for example
,$? - Is it preferable to use fixed length fields?
Any suggestion would be appreciated.
The best suggestion will be accepted.
Standard practice is to use a delimiter (usually comma ,) and a text qualifier (usually double quote “)
The output is then:
“Field A”,”Field B”,”Field With, A Comma”
Using a text qualifier means you do not need to worry about the delimiter appearing in your fields.
And I wouldn’t bother using fixed widths, that could lead to truncation later on if you change the design of the table and forget to update all of your export scripts.
Use the csv extension (file.csv) so that other programs recognise the file type. CSV stands for Comma Seperated Values.