Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Problem with DTS.variables in script task


Problem with DTS.variables in script task

Author
Message
Alistair Robertson
Alistair Robertson
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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
ab5sr
ab5sr
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 699
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search