0

I'm trying to create a filename dynamically. I'm able to get the date but i need the rowcount of the data that was read from the odbc source.

I created a int32 variable called 'rowcount'. And in the expression for the flat file connection manager 'connection string' property I have the following:

"E:\\path\\" + (DT_WSTR,4)DATEPART("yyyy",GetDate()) + RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) + RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2) + "_" + (DT_WSTR, 20) @[User::rowcount]  +".csv" 

which gives :

E:\folderpath\20151218_0.csv

But when I run the project it is creating the file name with 0 instead of the row count.

Any help would be appreciated. Thanks.

2
  • You don't describe what you are doing to actually populate the rowcount variable. Did you forget that step? Dec 18, 2015 at 19:38
  • sorry I did. I put a row count after the odbc source. odbc source --> row count --> flat file destination
    – Aliyyah K
    Dec 18, 2015 at 19:45

1 Answer 1

1

Ok, the problem is that your flat file is getting created (and therefore, named) before your DataFlow runs, when your rowcount variable is still zero because it hasn't been populated yet.

The only way to handle this is to rename the flat file after you have populated it and gotten the rowcount. And the only way to do this is with a Script Task that runs after your DataFlow task.

1
  • thanks much. I was able to use a file system task instead to rename the file in the control flow.
    – Aliyyah K
    Dec 18, 2015 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.