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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Writing multiple SQL Tables to one Text file

Author  Topic 

richumpire
Starting Member

2 Posts

Posted - 2008-04-07 : 17:24:42
I am trying to create a text file from multiple SQL Tables using @BCP_Command. I tried using DTS and SQL but the number of columns in the tables have to be the same size when doing a union. I also not to place a delimeter between each column. I've learned how to use BCP_commands on one file not sure if you can make it work with two or more.

Rich Pezick

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-07 : 17:28:49
Just put them all into separate files, then append them together via a DOS command:

type C:\SomeDir\*.bcp > C:\SomeDir\Append.txt

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

richumpire
Starting Member

2 Posts

Posted - 2008-04-07 : 17:35:24
Tara,
Thanks for that advice. I did think of that. I was trying to automate this somewhat so I would not have to touch as many things. Plus, I'm sending this out to a client and I have to do it multiple times over a 6-7 month period of time.

Rich Pezick
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-07 : 17:52:32
It can easily be automated.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -