virtualranger
Technical User
I need to create a .txt file for uploading some of our sql server based data into another comapany's database (non-sql). It's a daily upload so the file creation needs to be automated.
The file needs to consist of a header, a definition (detailing the data attributes), and the data itself. The Header, and definition are constant, it is only the data section that will change on each upload.
E.g. The file content will look exactly like this:
#HEADER#
EOF:'^'
EOR:'~'
#DEFINITION#
AGENT_REF^DATE^PROPERTY_ID^ADDR1^TOWN^COUNTY^
#DATA#
RQ12345^12/01/2005^00001^11 SOUTH STREET^TAUNTON^SOMERSET~
RQ12345^12/01/2005^00002^43 NORTH STREET^TAUNTON^SOMERSET~
RQ12345^12/01/2005^00003^18 WEST STREET^TAUNTON^SOMERSET~
#END#
I have no idea of the best way to do this! I can get the data out into a txt file with all the correct separators ('^' and '~') by using bcp command and xp_cmdshell, but I have no idea how to automatically insert the header and definition. Does anyone know if is possible to do the whole thing via DTS, or perhaps an alternative method?
Thanks,
Jamie
The file needs to consist of a header, a definition (detailing the data attributes), and the data itself. The Header, and definition are constant, it is only the data section that will change on each upload.
E.g. The file content will look exactly like this:
#HEADER#
EOF:'^'
EOR:'~'
#DEFINITION#
AGENT_REF^DATE^PROPERTY_ID^ADDR1^TOWN^COUNTY^
#DATA#
RQ12345^12/01/2005^00001^11 SOUTH STREET^TAUNTON^SOMERSET~
RQ12345^12/01/2005^00002^43 NORTH STREET^TAUNTON^SOMERSET~
RQ12345^12/01/2005^00003^18 WEST STREET^TAUNTON^SOMERSET~
#END#
I have no idea of the best way to do this! I can get the data out into a txt file with all the correct separators ('^' and '~') by using bcp command and xp_cmdshell, but I have no idea how to automatically insert the header and definition. Does anyone know if is possible to do the whole thing via DTS, or perhaps an alternative method?
Thanks,
Jamie