all groups > sql server dts > january 2004 >
You're in the

sql server dts

group:

Create extra empty fields in a csv file using dts


Create extra empty fields in a csv file using dts les
1/14/2004 11:28:29 PM
sql server dts: I'm exporting data to a csv file which needs to include some fields
that I dont have in my source table.

Some of these will have no value but must still be included in the csv
file

one will have a static value for all records and one will contain a
static URL ending in a querystring value from a data field (eg:
http://mydomain.com/filename?id=<my id field> )

How do I do this? I would appreciate any suggestions.
Thanks
Re: Create extra empty fields in a csv file using dts les
1/14/2004 11:31:26 PM
forgot to mention I'm using sql 2000

Leslie

[quoted text, click to view]
Re: Create extra empty fields in a csv file using dts Darren Green
1/15/2004 6:41:31 AM
In message <dljb00hdhrg5q4vf95otqrjkcuvunvtsna@4ax.com>, les@?.?.invalid
writes
[quoted text, click to view]

The simplest way to do this would be to use a source query like this-

SELECT Col1, Col2, Col3, '' AS Col4, '' AS Col5,
'http://mydomain.com/filename?id= + CAST(Col6 AS varchar(255)) AS Col6
FROM MyTable

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org
Re: Create extra empty fields in a csv file using dts Allan Mitchell
1/15/2004 6:41:33 AM
OK the way I do this is:

1. In the Source Query statement add place holders.

select .............................., 'NewField' as NewField1, 'NewField'
as NewField2 from table

2. The text file will get created with two extra attributes

3. In the transformations section do not highlight the source attributes of
NewField and NewField2 highlight the others.
4. New Active script transform.

Function Main()
DTSDestination("au_id") = DTSSource("au_id")
DTSDestination("au_lname") = DTSSource("au_lname")
DTSDestination("au_fname") = DTSSource("au_fname")
DTSDestination("phone") = DTSSource("phone")
DTSDestination("address") = DTSSource("address")
DTSDestination("city") = DTSSource("city")
DTSDestination("state") = DTSSource("state")
DTSDestination("zip") = DTSSource("zip")
DTSDestination("contract") = DTSSource("contract")
DTSDestination("NewField") = "My Value 1"
DTSDestination("NewField2") = "MyValue 2"
Main = DTSTransformStat_OK
End Function

You obviously sub in your value for the new fields.

the outcome looks like this

"au_id","au_lname","au_fname","phone","address","city","state","zip","contra
ct","NewField","NewField2"
"172-32-1176","Mitchell","Johnson","408 496-7223","10932 Bigge Rd.","Menlo
Park","CA","94025",True,"My Value 1","MyValue 2"


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


[quoted text, click to view]

Re: Create extra empty fields in a csv file using dts les
1/15/2004 10:26:31 PM
Thanks, that was what I needed.

Leslie

On Thu, 15 Jan 2004 06:41:31 +0000, Darren Green
[quoted text, click to view]
AddThis Social Bookmark Button