Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-01-28 : 08:23:20
|
| Ian writes "Hi,I've created a stored proc to output a fixed-length text file for a data warehouse flat-file upload. To achieve the fixed-length output, I've created a temp table with all CHAR datatypes. This works great, but upon outputting this to a text file either using Query Analyzer or OSQL, the actual number of spaces for each field is sized to accommodate the column alias name. So, if I have a 10 char ID field that was created as a CHAR(10) field, but the alias name of the field is 12 characters long, then my output ends up having 2 extra spaces added to the right side of the data, effectively ruining the fixed-length paradigm.Any ideas? I've already turned off the column headers in the output, but that doesn't make any difference.- Ian" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-01-28 : 08:25:24
|
| Use bcp instead of osql. bcp is described in Books Online, it would fit your needs perfectly. A quick example:bcp "mydatabase..mytable" out myfile.txt -S myserver -T -c -t""That will export the contents of mytable to myfile.txt. The -t"" switch tells bcp to use an empty string (nothing) as a column delmiter. That should give you the fixed-length format you want. |
 |
|
|
|
|
|