Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Problem with DTS.variables in script task Expand / Collapse
Author
Message
Posted Wednesday, June 24, 2009 4:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 14, 2009 4:05 AM
Points: 2, Visits: 27
Hi,

I'm having a problem with the DTS.variables("MY_VAR").Value.ToString component in my script task in an SSIS package I've created.

In order to get around all the inherent environmental issues we have I've had to create a process that backloads historical data if/when my job falls over.

To do this I've populated and ADO-recordset with the dates that I need to load (I do this from a SQL Server datasource query) so I've got SQL server dates (this could be 1 day of maybe 2-3 if the dB/job has fallen over).

I then use a for each loop to use the results of the ADO-recordset and do my loading logic for each day that exists in the for each loop container. Great in theory but the database I'm loading the data from is dB2 and it doesn't recognise SQL server datetime format - it has to be 'dd/mm/yyyy' or 'yyyy-mm-dd'. So I've change my dates in the ADO-recordset using convert(char(10),'2009-06-24 00:00:00.000',120).


So now I have some dates in the format '2009-06-24' which dB2 can cope with. I then create a variable in a script task to turn the object variable into a string: -
Dts.Variables("MY_VAR").Value = Dts.Variables("LOAD_DATES").Value.ToString
I then use MY_VAR to drive my query running against dB2 in another script task (I'm using SQL as a string in VB here) i.e. " AND DATE_COLUMN = '"+ Dts.Variables("MY_VAR").Value.ToString + "' + _

This is where my problem is when I put in Dts.Variables("MY_VAR").Value.ToString it does not keep the string as '2009-06-24' for some reason it adds 00:00:00 to the date and dB2 throws a wobbly because it doesn't like it. It's like SSIS is saying well hey that looks like a date some I'm going to add some zero's to it?!

The only way round it I've found is to write a big string manipulation statement in dB2 using the date in the format SSIS gives is off '2009-06-24 00:00:00'. I think there has to be an easier way of doing this and my limited knowledge of VB .net is holding me back here. The other problem is the complex string manipulation takes ages to run against the dB.

If you guys can think of a simple way round this that would be great...apologies for the vast amount of detail, I thought it might help.

Cheers, Ally





Post #740904
Posted Wednesday, June 24, 2009 5:40 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 9:47 AM
Points: 214, Visits: 641
Try using ShortDateTime with DateTime.Parse. Check this link and see if anything there might help.

http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx





Lee Everest

Post #740926
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse