JinjaNinjaUK
Programmer
Hi All,
I wonder if anyone can assist me. I'm trying to create a DTS that will import bespoke XLS files into SQL2K5. I've used the Dynamic Properties Task to control the source data and to point it at the file in question, and I've added an ActiveX task to ensure that the import uses the IMEX=1 flag to avoid the issues surrounding mixed-format columns being imported into SQL, both of which work fine.
My problem now is that the files that the users will be uploading could contain any number of columns from 2 to 20. Because of this, I've realised that I'm going to struggle to transform the data, as there seems to be no way of "redoing the auto-mapping" programmatically.
I've found the following piece of code that looks like it might begin to solve the problem, but I can't seem to find a way of identifying the number of active columns included in the XLS (prior to transform) to allow me to run through a loop that sets up the required number of transforms. (I'm aware the code below is far from working, but I wanted to include as it does appear to address the problem.)
I'm trying to avoid installing Excel on the webserver, and want to try and make this as painless as possible for the individuals uploading the files.
Anybody got any ideas? They'd be much appreciated! Is there any way I can combine my pre-transformed XLS file into a view so that it always has, say, 50 columns? Something like this may allow me to import into a 50 column table, from which I can trim out excess columns, and move to a table of it's own.
In case it helps, the system is intended to allow external staff to upload an XLS file, in any format, which they then identify as something like "Contacts","Pricelists",etc. Following the import of the file, they then identify the fields contained, and match them against a vocabulary of attributes for the relevant type. (e.g Contacts would have "First Name","Surname","Full Name","Initial","Salutation" etc) and they then match any or all of the uploaded fields to the fields specified in the vocabulary. Obviously, the intention is to then update a table of data elsewhere with this information, based on the translation specified. To deliver this how I would like to, I would need the information within SQL prior to requesting field information, so putting this behind the field selection to ascertain the number of fields is not really an option.
Any and all help would be much appreciated.
I wonder if anyone can assist me. I'm trying to create a DTS that will import bespoke XLS files into SQL2K5. I've used the Dynamic Properties Task to control the source data and to point it at the file in question, and I've added an ActiveX task to ensure that the import uses the IMEX=1 flag to avoid the issues surrounding mixed-format columns being imported into SQL, both of which work fine.
My problem now is that the files that the users will be uploading could contain any number of columns from 2 to 20. Because of this, I've realised that I'm going to struggle to transform the data, as there seems to be no way of "redoing the auto-mapping" programmatically.
I've found the following piece of code that looks like it might begin to solve the problem, but I can't seem to find a way of identifying the number of active columns included in the XLS (prior to transform) to allow me to run through a loop that sets up the required number of transforms. (I'm aware the code below is far from working, but I wanted to include as it does appear to address the problem.)
Code:
=======================
'Add transformations for DataPump task
Set tran = cusData.Transformations.New("DTS.DataPumpTransformScript.1")
tran.Name = "DTSTransformation__1"
'Add Source columns for transformation
Set col = tran.SourceColumns.New("au_id", 1)
col.Name = "au_id"
col.Ordinal = 1
tran.SourceColumns.Add col
Set col = Nothing
'Add Destination columns for transformation
Set col = tran.DestinationColumns.New("AuthorID", 1)
col.Name = "AuthorID"
col.Ordinal = 1
tran.DestinationColumns.Add col
Set col = Nothing
=======================
Anybody got any ideas? They'd be much appreciated! Is there any way I can combine my pre-transformed XLS file into a view so that it always has, say, 50 columns? Something like this may allow me to import into a 50 column table, from which I can trim out excess columns, and move to a table of it's own.
In case it helps, the system is intended to allow external staff to upload an XLS file, in any format, which they then identify as something like "Contacts","Pricelists",etc. Following the import of the file, they then identify the fields contained, and match them against a vocabulary of attributes for the relevant type. (e.g Contacts would have "First Name","Surname","Full Name","Initial","Salutation" etc) and they then match any or all of the uploaded fields to the fields specified in the vocabulary. Obviously, the intention is to then update a table of data elsewhere with this information, based on the translation specified. To deliver this how I would like to, I would need the information within SQL prior to requesting field information, so putting this behind the field selection to ascertain the number of fields is not really an option.
Any and all help would be much appreciated.