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
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 help with bcp - header and trailer records

Author  Topic 

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-08-20 : 19:51:25
I just got a project to send some detail records from a SQL Server view to another system (mainframe). The specs call for a header record which has date and some other fixed values. The specs also call for a trailer record which has a rowcount along with some other fixed fields.

What's the best approach to constructing the file using bcp/DTS with these requirements. I'm sure some of you have had to do this before.

Thanks

dsdeming

479 Posts

Posted - 2002-08-21 : 08:26:46
What I've done in cases like this is to create a table with a single column large enough to hold the widest row, insert the header, insert the details, and insert the trailer. Then it's easy enough to bcp/DTS the data out.

HTH

Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-21 : 08:49:05
We write extract files for loading into our SAP system from our Internet databases. We use bcp. Because our records have a 2 digit identifier as the start of each row we use this to order the eventual export i.e. 00 is the header 99 is the footer and in between are the various types of record e.g. Order,Enrolement,Payment etc.
Basically all the data to be extracted is collected in temp tables,transformed if required and then loaded into an export table
We then use bcp to export the data from the table to flat file



HTH
Jasper Smith
Go to Top of Page
   

- Advertisement -