Mark Kadlec
Mark Kadlec

Reputation: 8440

Using SSIS, how do you read a datetime field into a variable that is of Data Type string?

This one has bugged me for the longest time and a great question to ask the Stackoverflow users I think.

I have a rather large SSIS flow that uses a string variable to store the datetime. I would now like to dynamically read the datetime value from the database, but how would you construct the SSIS to do this?

My first obvious thought would be to simply execute a SQL task to get the datetime and store it in the variable, but got the "differs from the current variable type" error.

Is there a simple way to convert the database datetime into a String variable?

Any help from the community would be appreciated,

Upvotes: 1

Views: 1168

Answers (1)

HLGEM
HLGEM

Reputation: 96552

Sure you use a derived column and convert the data from the datbase column to one of the correct type.

Another method would be to use t-sql code as your data source and do the cast inthe t-sql code so that the field comes into the dataflow as string.

Or of course you could change the string to a date type.

Upvotes: 3

Related Questions