how to capture timestamp with milliseconds in ssis package 2016

余生颓废 提交于 2019-12-11 00:40:05

问题


How to capture current timestamp in ssis package 2016

I declared a variable and using expression but milliseconds are missing

@currenttimestamp = (DT_WSTR,50)(DT_DBTIMESTAMP)@[System::StartTime]

I want the milliseconds too

Thanks


回答1:


The issue was solved when casting to (DT_DBTIMESTAMP2,3):

(DT_WSTR,50)(DT_DBTIMESTAMP2,3)GETDATE()

but the time get changes as it using the getdate() asit returns the current time, I need the package start time I used the following

(DT_WSTR,50)(DT_DBTIMESTAMP2,3)@[System::StartTime] 

but the milliseconds is coming as .000

Do i have to use the getdate() in ExecuteSQLTask and assign that value to a string variable. I am new to ssis please give suggestions.




回答2:


Use the below comand in the Execute SQL Task at the begining of the package that will give you the exact start time of the package.

SELECT CAST(GETDATE() as datetime2(6)) 'Date';


来源:https://stackoverflow.com/questions/49104035/how-to-capture-timestamp-with-milliseconds-in-ssis-package-2016

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!