Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Transformation and leading zeros

 
   Database Help (Home) -> DTS RSS
Next:  xml_set_character_data_handler  
Author Message
Bird Byte

External


Since: Oct 20, 2008
Posts: 2



(Msg. 1) Posted: Mon Oct 20, 2008 10:44 am
Post subject: Transformation and leading zeros
Archived from groups: microsoft>public>sqlserver>dts (more info?)

I have a DTS package with an Excel spreadsheet as the source and a text file
as the destination. There is a transformation that occurs on the data to
format it correctly (certain fields need quotes, others, namely date and zip
fields, do not have quotes). It works except for the zip code field. If the
first number is a zero, it gets dropped. There doesn't seem to be a way to
change the character length behind the transformation action - at least it
wouldn't let me change the default 255 length.
I am able to accomplish this when I do an import/export in Enterprise
Manager, but not in the DTS package.
If you respond, please keep in mind I am new to writing DTS packages.
Thanks much, and let me know if I need to provide more info.

 >> Stay informed about: Transformation and leading zeros 
Back to top
Login to vote
Todd C

External


Since: Jan 31, 2007
Posts: 98



(Msg. 2) Posted: Tue Oct 21, 2008 5:51 am
Post subject: RE: Transformation and leading zeros [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

If you can use a standard SQL statement when pulling the data out of the
Excel file, then you can use something like this:

SELECT
RIGHT("000" + ZipCode, 5 ) AS ZipCode
FROM ...

It adds 3 leading zeros to the field, then takes the last five of the
result. I had the same issue and have seen solutions that first examine the
length and if it's 4, add a zero, and if it's 3 ... etc, but this is simple.

HTH
--
Todd C

"Bird Byte" wrote:

> I have a DTS package with an Excel spreadsheet as the source and a text file
> as the destination. There is a transformation that occurs on the data to
> format it correctly (certain fields need quotes, others, namely date and zip
> fields, do not have quotes). It works except for the zip code field. If the
> first number is a zero, it gets dropped. There doesn't seem to be a way to
> change the character length behind the transformation action - at least it
> wouldn't let me change the default 255 length.
> I am able to accomplish this when I do an import/export in Enterprise
> Manager, but not in the DTS package.
> If you respond, please keep in mind I am new to writing DTS packages.
> Thanks much, and let me know if I need to provide more info.
>

 >> Stay informed about: Transformation and leading zeros 
Back to top
Login to vote
Bird Byte

External


Since: Oct 20, 2008
Posts: 2



(Msg. 3) Posted: Tue Oct 21, 2008 8:08 am
Post subject: RE: Transformation and leading zeros [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks. When I posted I didn't realize that to change a transformation
mapping you first have to delete the existing one then create a new one. I
added an ActiveX Script for that field that works:

Function Main()
DTSDestination("ZipCode") = Right("00000" +
(DTSSource("ZipCode")), 5)
Main = DTSTransformStat_OK
End Function

Thanks for the help.


"Todd C" wrote:

> If you can use a standard SQL statement when pulling the data out of the
> Excel file, then you can use something like this:
>
> SELECT
> RIGHT("000" + ZipCode, 5 ) AS ZipCode
> FROM ...
>
> It adds 3 leading zeros to the field, then takes the last five of the
> result. I had the same issue and have seen solutions that first examine the
> length and if it's 4, add a zero, and if it's 3 ... etc, but this is simple.
>
> HTH
> --
> Todd C
>
> "Bird Byte" wrote:
>
> > I have a DTS package with an Excel spreadsheet as the source and a text file
> > as the destination. There is a transformation that occurs on the data to
> > format it correctly (certain fields need quotes, others, namely date and zip
> > fields, do not have quotes). It works except for the zip code field. If the
> > first number is a zero, it gets dropped. There doesn't seem to be a way to
> > change the character length behind the transformation action - at least it
> > wouldn't let me change the default 255 length.
> > I am able to accomplish this when I do an import/export in Enterprise
> > Manager, but not in the DTS package.
> > If you respond, please keep in mind I am new to writing DTS packages.
> > Thanks much, and let me know if I need to provide more info.
> >
 >> Stay informed about: Transformation and leading zeros 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
SSIS transformation error - I am having problems in transformation task. I am retrieving oracle data and loading into sql server table. Oracle retrieval works fine, at the time of loading its giving some problem. It is pretty straight forward load to sql server. When I switched....

DTS Transformation Error - I am using an already developed DTS package that I created for a new database. Everything looks the same here. Except now I am getting this nasty transformation message... An error occurred when you tried to submit changes to this transform. Please ..

IsBig Property of Aggregator Transformation - Hi, How do I set the IsBig Property of Aggregator transformation in SSIS? Regards, Gayatri.

How to define Transformation when there is Temporary table? - I am using SQL Server 2000 DTS package. I am trying to re-define transformations between the source and destination tables while there are Temporary tables, and it is causing an error message. Is there anyway I could do it like "at edit mode&quot...

Enable Memory Restriction for Lookup Transformation - Hi, We can enable memory restriction (limit cache size) for “Lookup Transformation" in Data Flow Task, can someone tell me how exactly it effects the performance of the package? I’m fetching 35 million records from source database and having looku...
   Database Help (Home) -> DTS All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]