all groups > sql server dts > march 2005 >
You're in the

sql server dts

group:

dynamic source columns


dynamic source columns JFB
3/14/2005 3:07:46 PM
sql server dts:
Hi All,
Every time I importing a text file the columns name change.
I can collect all the source columns in a string, when I call the pkg I pass
this string as GV.
In my Transformation I want to change change the name of the source columns.
How can I do this ?
Tks
JFB

Re: dynamic source columns JFB
3/14/2005 3:27:52 PM
Tks for you reply and help Allan,
Can i do this steps dynamicly?
I have this for script on the transformation, ir works if I run the package
manually, but If I change the source file the source columns remain there.
Also the table has a primary key.
Rgds
JFB

'**********************************************************************
' Visual Basic Transformation Script
'************************************************************************

' Copy each source column to the destination column
Function Main()
'Declare Variables
Dim SourceArray, DestiantionArray, count, temp, Field

'Get Field values from GVs arrays
SourceArray = Split(DTSGlobalVariables("SourceFields").Value, ",")
DestinationArray = Split(DTSGlobalVariables("DestinationFields").Value,
",")

count = 0 'Initialize counter

'Loop thru array and import columns to table
For Each Field In SourceArray
If Not IsNull(Field) then
'MsgBox Field
DTSDestination(DestinationArray(count)) = DTSSource(Field)
End if
count = count + 1
next

Main = DTSTransformStat_OK
End Function



[quoted text, click to view]

Re: dynamic source columns JFB
3/14/2005 3:43:30 PM
Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

[quoted text, click to view]

Re: dynamic source columns JFB
3/14/2005 4:07:15 PM
Tks Allan,
I really appreciate you help. j.balladares@verizon.net
Rgds
JFB

[quoted text, click to view]

Re: dynamic source columns JFB
3/14/2005 5:23:07 PM
Allan,
Tks for the example... now I have another problem.
Sometimes we want to use the same source column in two diferent destination
columns.
I'm getting an error saying the Tranformatio_columName already exist.
How can I fix that?
Rgds
JFB

[quoted text, click to view]

Re: dynamic source columns Allan Mitchell
3/14/2005 8:24:53 PM
I would do it like this

1. Remove existing transforms
2. Create a new transformation object for each source column
3. Add the SourceColumn to the Transformation
4. Add a DestinationColumn to the transformation
5. Add the transformation to the transformations collection


Allan


[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
3/14/2005 8:37:03 PM
Yes you can do it dynamagically.

I have posted before about a script I wrote in ActiveX task that took a
Query, Parsed it, created a table in Excel and the created the mappings.

Allan

[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
3/14/2005 8:58:44 PM
Throw me a mail and I'll post the package

[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
3/15/2005 6:54:50 AM
It is relatively easy to do.

The best way would be to design a package in designer that does what you
want and then save as a VB module. Have a look in there at how DTS
itself does it.

Allan

[quoted text, click to view]
Re: dynamic source columns Juliane
3/15/2005 10:17:04 AM
Hi Allan,

i have a similar problem: Importing text files and do not know in advance
how many columns the files have. Can you send me your example too ? THANS so
much !

JulianeB@Hotmail.com

Juliane

[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
3/15/2005 7:06:41 PM
Done

[quoted text, click to view]
Re: dynamic source columns Peter
3/21/2005 4:17:02 AM
Alan

Please send me a copy. I've been looking for this solution for a long time.

Regards
Peter

[quoted text, click to view]
Re: dynamic source columns Peter
3/21/2005 5:25:02 AM
Alan sorry my email is avenants@gmail.com

Thanks
Peter

[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
3/21/2005 7:20:22 PM
Juliane has taken care of this for me.

Thanks Juliane

Allan

[quoted text, click to view]
Re: dynamic source columns Lak Mal
4/13/2005 10:35:31 AM


Hi Allan,

I am looking for this solution for a long time, can you post the code.

Thanks,
Lak

Re: dynamic source columns Allan Mitchell
4/13/2005 6:14:49 PM
The code is inside a package so ping me by eMail and I'll send it along

[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
4/26/2005 12:00:00 AM
done

--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


[quoted text, click to view]
Re: dynamic source columns Yuliaan
4/26/2005 8:54:04 AM
Alan

I've encountered the same problem. Could you send me a copy too?
My mail: olegrom@012.net.il

Regards
Yuliaan


[quoted text, click to view]
Re: dynamic source columns Allan Mitchell
5/25/2005 12:00:00 AM
On its way

[quoted text, click to view]
Re: dynamic source columns Shannon Winterton
5/25/2005 12:32:30 PM


Alan,
Dito, could you also please send to me as well.
gitsupport@hotmail.com
Shannon

AddThis Social Bookmark Button