Tips for preparing text files (for later use by BCP)….

Naturally, the first choice is to just use BCP itself:

bcp “SELECT * MyDataBaseNameHere.MySchemaNameHere.MyTableNameHere”  queryout c:\blah.csv  -S ServerNameHere -T -t “|” -c

 Or, for those little times where you just need a delimited bunch of rows of the data in a table, do the following to leverage Sql Server Management Studio:

  1. Open a new query window.
  2. Set the Query\Results To\Results to Text
  3. Go to Query\Query Options \Results\Text and make the following settings:
    • Output format:  Custom Delimiter
    • Specify the custom delimiter
    • Turn off “Include column headers in the result set”
    • Expand the Maximum number of characters displayed ( set to the highest of 8192)
  4. Run your query, copy the text into your text file.

Ok, kind of a lame post.

 J