Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Expression in derived column

Author  Topic 

sanjnep
Posting Yak Master

191 Posts

Posted - 2007-09-06 : 10:45:58
I want to write expression on derived column in SSIS package like
IF Termdate <> "" THEN CDate(Termdate) ELSE NULL
END IF

Can any one help for me?
Thanks
Sanjeev

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-06 : 10:55:52
CASE WHEN Termdate <> "" THEN CDate(Termdate) ELSE NULL END


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sanjnep
Posting Yak Master

191 Posts

Posted - 2007-09-06 : 11:13:10
No I want to write this on expression box of derived column in data flow task (SSIS) not in SQL statements.
Thanks
Sanjeev
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-09-06 : 11:58:24
One way to do it is:
LEN(TRIM(Termdate)) > 0 ? (DT_FILETIME)Termdate : NULL(DT_FILETIME)

You might want to look up the different types of Date/Time types to see which one makes sense. Here is a quick rundown from BOL:
Data type      Date format 
--------------------------------------------
DT_DBDATE yyyy-mm-dd
DT_FILETIME yyyy-mm-dd hh:mm:ss:fff
DT_DBTIME hh:mm:ss
DT_DBTIMESTAMP yyyy-mm-dd hh:mm:ss:fffffffff


Go to Top of Page

sanjnep
Posting Yak Master

191 Posts

Posted - 2007-09-06 : 12:11:43
Thanks a lot Lamprey
Sanjeev
Go to Top of Page
   

- Advertisement -