kapz
kapz

Reputation: 457

Get DateTime value from DB into a variable in SSIS

I'm taking the last updated date from SQL table as below:

SELECT CONVERT(DATETIME, [Value]) AS LastModifiedDate 
FROM [WarehouseDB].[dbo].[tblWarehouseSettings]
WHERE Name = 'LastModifiedDate'

[Value] is varchar.

A variable as below:

Variable

I'm using an Execute SQL Task to get the date value & assign it to the variable. My Execute SQL Task Editor values set as below:

General

Parameter Mapping

enter image description here

The task executed successfully but it doesn't get the value from the DB. Assigned value to the variable after the task execution is {12/30/1899 12:00:00 AM}

Can anyone figure out what I'm doing wrong here?

Upvotes: 2

Views: 9241

Answers (1)

Hadi
Hadi

Reputation: 37313

There are 2 things that caused this issue :

  1. There is no need to specify @[User::LastUpdateOn] as an Output parameter in Parameters mapping Tab
  2. Your SQL Statement is showing that you are converting [Value] column to DATETIMEOFFSET instead of DateTime and DT_DBTIMESTAMP is related to DateTime SQL Data Type

References

Upvotes: 2

Related Questions