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.
Author |
Topic |
NguyenL71
Posting Yak Master
228 Posts |
Posted - 2015-02-02 : 11:21:54
|
I am try to output an excel file with dynamic date. Here what I done.1. Create Execute SQL Task Connect Type: Excel2. Create Data Flow Task set to DelayValidation: True3. Create OLE DB Sourc4. Create Data Converstion5. Excel Destination6. Excel Connection, Expression, select ExcelFilePath7. @[User::sXLFilePath] + @[User::sFileName] + RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", GETDATE()), 2)+ RIGHT("0" + (DT_WSTR, 2) DATEPART("MM", GETDATE()), 2) + RIGHT((DT_WSTR, 4) DATEPART("YYYY", GETDATE()), 2) +".csv"8. C:\ExcelOutPut\SOX_CAM_SQL_Report_010215.xlsWhat I try to accomplish is output the file with each day append to it, date must be DDMMYY.I google it and found many samples, tested it, and none of them is work for me. Any suggestions or some examples to share is greatly appreciate. I am new to SSIS. I found one poster have similar issue and inside the posted below, there was one suggestion to create variable and connection string but how do I bind that variable to Excel Connection manger.Please help.Thank you so much in advance.Ex: SOX_CAM_SQL_Report _020215.csv SOX_CAM_SQL_Report _030215.csv --Similar issue:https://social.msdn.microsoft.com/Forums/en-US/bda433aa-c8f8-47c9-9e56-efd20b8354ac/creating-a-dynamic-excel-file?forum=sqlintegrationservicesSuggestion in the above posted but where can bind this to Excel Connection Manger. Please help provide step by step. Thanks."Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\temp\\" + "ExcelTarget" + (DT_WSTR,4)DATEPART("yyyy",GETDATE()) + ".xls" + ";Extended Properties=\"EXCEL 8.0;HDR=YES\";"And yes, as you were intimating, the delay validation on the dataflow should be set. |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-02 : 13:27:06
|
At first glance it seems that you are on the right track.Questions:1. Do you want filetype to be csv or xls? If csv, just use flat file destination2. Is your solution giving error messages (if so, post them)3. If you're not getting errors, please post the filenames being generated by your expression. |
|
|
NguyenL71
Posting Yak Master
228 Posts |
Posted - 2015-02-02 : 17:17:47
|
I just want to output csv. The package did not give an error but whenI look at the excel file, nothing is output. Here is my steps:Change my system date to 02/03/15, 02/04/15, ect...run the package, it ran fine but when I change my system date back to today and deleteall the package except the template than nothing ran.btw, when I look at the Excel Connection manager, Edit and is pointto the file below. How can I force always to use the file name and append just date to it?. Thanks.C:\ExcelOutPut\SOX_CAM_SQL_Report_020215.xlsWhat am I missing here?How can I upload images to this my post?quote: Originally posted by gbritton At first glance it seems that you are on the right track.Questions:1. Do you want filetype to be csv or xls? If csv, just use flat file destination2. Is your solution giving error messages (if so, post them)3. If you're not getting errors, please post the filenames being generated by your expression.
|
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-02 : 21:19:08
|
if you want CSV use a flat file connector not excel |
|
|
NguyenL71
Posting Yak Master
228 Posts |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-03 : 12:17:15
|
I suggest you work through the Stairway to SSIS: http://www.sqlservercentral.com/stairway/72494/ |
|
|
|
|
|
|
|