I need to export data from a SQL table into a text file with fixed positions defined as constants.

I wrote the following script for this export using Nortwind DB:

declare @arm char(2), @cliente char(5), @typ char(3), @na1 char(2), @ref char(15), @str char(27)
select @arm = '51', @cliente = '00717', @typ = 'REF', @na1 = ' '
set @ref = (SELECT CustomerID FROM Northwind..Customers where CustomerID = 'CACTU')
select @str = @arm + @cliente + @typ + @na1 + @ref
select @str

The result is:

5100717REF CACTU


How can I use this script on a DTS in order to export all records from the Customers table keeping the format "5100717REF" and adding the CustomerID as variable to get the different rows on the table to the export file.


The expected result is a text file containing all table rows:

5100717REF ALFKI
5100717REF ANATR
5100717REF ANTON
5100717REF CACTU
5100717REF WOLZA

Thanks for your help in advance!