bcp to a text file

I need to convert a table to a text file(MSSQL 6.5) on fixed length format(no commas or tab terminators)
that is what i got so far:
bcp db.dbo.table1 out file.txt /c /Sdb /Usa /PPASSWORD> test.log
eliasisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gandalf32Commented:
That command will create a tab delimited file. If you need a fixed file, then you need to create a format file (with the -f parameter). Simply do not include the /c parameter, and the bcp command will allow you to create the format file.
0
Gustavo Perez BuenrostroCommented:
You can specify /t and /r arguments of BCP utility to avoid field and row terminator in output file. Remember that the default values are (tab and newline character).

You can change the default field terminator to specify no terminator value using /t argument with no value (/t).

According to your code:

bcp db.dbo.table1 out file.txt /c /t /Sdb /Usa /PPASSWORD /otest.log
0
eliasisAuthor Commented:
I tried "/t argument with no value", but I get blank space between every field
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

eliasisAuthor Commented:
I tried "/t argument with no value", but I get blank space between every field
0
rayasamCommented:
If you want to use bcp to output to a text file as fixed length  use bcp format file. issue the sbove bcp command without a /c. Bcp will prompt you for the length and the column terminator. Do not provde a column terminator except for the last column.

Hop this helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
simonsabinCommented:
You will need to use the /f to create a format file and then subsequently you can specify the format file you have just created.
0
Gustavo Perez BuenrostroCommented:
Try using 0 value for the field terminator and let me know haw it works for you:

bcp db.dbo.table1 out file.txt /c /t0 /Sdb /Usa /PPASSWORD /otest.log
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.