dbTalk Databases Forums  

dynamic source columns

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss dynamic source columns in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JFB
 
Posts: n/a

Default dynamic source columns - 03-14-2005 , 02:07 PM






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



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 02:24 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


"JFB" <help (AT) jfb (DOT) com> wrote


Quote:
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


Reply With Quote
  #3  
Old   
JFB
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 02:27 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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
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


"JFB" <help (AT) jfb (DOT) com> wrote


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




Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 02:37 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

"JFB" <help (AT) jfb (DOT) com> wrote


Quote:
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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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



Reply With Quote
  #5  
Old   
JFB
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 02:43 PM



Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
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

"JFB" <help (AT) jfb (DOT) com> wrote


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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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





Reply With Quote
  #6  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 02:58 PM



Throw me a mail and I'll post the package

"JFB" <help (AT) jfb (DOT) com> wrote


Quote:
Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:OgIdkTNKFHA.1096 (AT) tk2msftngp13 (DOT) phx.gbl...
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

"JFB" <help (AT) jfb (DOT) com> wrote


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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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




Reply With Quote
  #7  
Old   
JFB
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 03:07 PM



Tks Allan,
I really appreciate you help. j.balladares (AT) verizon (DOT) net
Rgds
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Throw me a mail and I'll post the package

"JFB" <help (AT) jfb (DOT) com> wrote


Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:OgIdkTNKFHA.1096 (AT) tk2msftngp13 (DOT) phx.gbl...
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

"JFB" <help (AT) jfb (DOT) com> wrote


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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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






Reply With Quote
  #8  
Old   
JFB
 
Posts: n/a

Default Re: dynamic source columns - 03-14-2005 , 04:23 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

"JFB" <help (AT) jfb (DOT) com> wrote

Quote:
Tks Allan,
I really appreciate you help. j.balladares (AT) verizon (DOT) net
Rgds
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:#cusrfNKFHA.3076 (AT) tk2msftngp13 (DOT) phx.gbl...
Throw me a mail and I'll post the package

"JFB" <help (AT) jfb (DOT) com> wrote


Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:OgIdkTNKFHA.1096 (AT) tk2msftngp13 (DOT) phx.gbl...
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

"JFB" <help (AT) jfb (DOT) com> wrote


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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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








Reply With Quote
  #9  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: dynamic source columns - 03-15-2005 , 12:54 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

"JFB" <help (AT) jfb (DOT) com> wrote


Quote:
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

"JFB" <help (AT) jfb (DOT) com> wrote in message
news:O2ilPnNKFHA.3296 (AT) TK2MSFTNGP15 (DOT) phx.gbl...
Tks Allan,
I really appreciate you help. j.balladares (AT) verizon (DOT) net
Rgds
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:#cusrfNKFHA.3076 (AT) tk2msftngp13 (DOT) phx.gbl...
Throw me a mail and I'll post the package

"JFB" <help (AT) jfb (DOT) com> wrote


Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:OgIdkTNKFHA.1096 (AT) tk2msftngp13 (DOT) phx.gbl...
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

"JFB" <help (AT) jfb (DOT) com> wrote


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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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







Reply With Quote
  #10  
Old   
Juliane
 
Posts: n/a

Default Re: dynamic source columns - 03-15-2005 , 12:17 PM



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 (AT) Hotmail (DOT) com

Juliane

"Allan Mitchell" wrote:

Quote:
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

"JFB" <help (AT) jfb (DOT) com> wrote


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

"JFB" <help (AT) jfb (DOT) com> wrote in message
news:O2ilPnNKFHA.3296 (AT) TK2MSFTNGP15 (DOT) phx.gbl...
Tks Allan,
I really appreciate you help. j.balladares (AT) verizon (DOT) net
Rgds
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:#cusrfNKFHA.3076 (AT) tk2msftngp13 (DOT) phx.gbl...
Throw me a mail and I'll post the package

"JFB" <help (AT) jfb (DOT) com> wrote


Do you remember the posted subject name?
Otherwise I will keep searching for it
Tks
JFB

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:OgIdkTNKFHA.1096 (AT) tk2msftngp13 (DOT) phx.gbl...
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

"JFB" <help (AT) jfb (DOT) com> wrote


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").Valu e,
",")

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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:ORM#wMNKFHA.3132 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


"JFB" <help (AT) jfb (DOT) com> wrote


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








Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.