dbTalk Databases Forums  

ActiveX script for transformation: how to know how many columns inDTSSource

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


Discuss ActiveX script for transformation: how to know how many columns inDTSSource in the microsoft.public.sqlserver.dts forum.



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

Default ActiveX script for transformation: how to know how many columns inDTSSource - 01-17-2006 , 01:42 PM






I use ActiveX script for data transformation. The source table and the
destination table are exactly the same. For a table that has two
columns, the following function works.

-------------
Function Main()
DTSDestination(1) = DTSSource(1)
DTSDestination(2) = DTSSource(2)

Main = DTSTransformStat_OK
End Function
-------------

The problem is, I don't know how many columns are there in a source
table (because I am looping through a list of tables).

??? How can I find out how many columns are there is a source table ????

For your info, I have tried the following and it doesn't work. The error
is like: DTSSource is not a valid object or function.

-----------------
Function Main()
dim n,i
n = 100
for i=1 to n
'msgbox("source_column1, name -" & DTSSource(1).name)
'msgbox("source_column1, value -" & DTSSource(1).value)

if DTSSource(i).name<>"" and not isNull(DTSSource(i).name) then
DTSDestination(i) = DTSSource(i)
else
msgBox("total columns :" & i-1)
exit for
end if
next

Main = DTSTransformStat_OK
End Function
---------------


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

Default Re: ActiveX script for transformation: how to know how many columns in DTSSource - 01-17-2006 , 01:56 PM






Hello q_test,


The SourceColumns property of a transform determine what can be used in a
transformation. How do you determine how many columns you have? You could
issue a query and parse the results. Another option would be to parse the
metadata tables from the source provider. In SQL Server you could issue
a query against the INFORMATION_SCHEMA.COLUMNS table. You would need to
dynamically build the transform each time.


Allan





Quote:
I use ActiveX script for data transformation. The source table and the
destination table are exactly the same. For a table that has two
columns, the following function works.

-------------
Function Main()
DTSDestination(1) = DTSSource(1)
DTSDestination(2) = DTSSource(2)
Main = DTSTransformStat_OK
End Function
-------------
The problem is, I don't know how many columns are there in a source
table (because I am looping through a list of tables).

??? How can I find out how many columns are there is a source table
????

For your info, I have tried the following and it doesn't work. The
error is like: DTSSource is not a valid object or function.

-----------------
Function Main()
dim n,i
n = 100
for i=1 to n
'msgbox("source_column1, name -" & DTSSource(1).name)
'msgbox("source_column1, value -" & DTSSource(1).value)
if DTSSource(i).name<>"" and not isNull(DTSSource(i).name) then
DTSDestination(i) = DTSSource(i)
else
msgBox("total columns :" & i-1)
exit for
end if
next
Main = DTSTransformStat_OK
End Function
---------------



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.