December 3, 2013 at 6:10 am
Hi all,
I've files with an unix timestamp as name. For instance filename: 1081277409
I've written a function that based on the filename returns the readable dateformat: 2004-04-06 16:50:09.000
I've done this by reading the folder contents (xp_cmdshell) and insert the filenames into a table, wrote a convert function and based on this I get the readable dateformat.
The last thing I need to do is to rename the file: 1081277409 to 2004-04-06 16:50:09.000 automatically.
Is this possible with a stored procedure? I've tried SSIS file task but this won't work.
Any tips would be highly appreciated. Thanks in advance.
December 3, 2013 at 7:36 am
Trestire (12/3/2013)
Hi all,I've files with an unix timestamp as name. For instance filename: 1081277409
I've written a function that based on the filename returns the readable dateformat: 2004-04-06 16:50:09.000
I've done this by reading the folder contents (xp_cmdshell) and insert the filenames into a table, wrote a convert function and based on this I get the readable dateformat.
The last thing I need to do is to rename the file: 1081277409 to 2004-04-06 16:50:09.000 automatically.
Is this possible with a stored procedure? I've tried SSIS file task but this won't work.
Any tips would be highly appreciated. Thanks in advance.
When you say it didn't work with SSIS did you get an error message? Remember that you can't have colons : in a file name.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
December 4, 2013 at 6:11 am
Sean Lange (12/3/2013)
Trestire (12/3/2013)
Hi all,I've files with an unix timestamp as name. For instance filename: 1081277409
I've written a function that based on the filename returns the readable dateformat: 2004-04-06 16:50:09.000
I've done this by reading the folder contents (xp_cmdshell) and insert the filenames into a table, wrote a convert function and based on this I get the readable dateformat.
The last thing I need to do is to rename the file: 1081277409 to 2004-04-06 16:50:09.000 automatically.
Is this possible with a stored procedure? I've tried SSIS file task but this won't work.
Any tips would be highly appreciated. Thanks in advance.
When you say it didn't work with SSIS did you get an error message? Remember that you can't have colons : in a file name.
If you're already using xp_cmdshell to to get the filenames to convert, why not use another shell where you execute the rename commands in DOS? It's pretty straightforward, but Sean hit the nail on the head - you cannot have a colon in a filename no matter how you approach it.
December 4, 2013 at 8:30 am
Heh... and stop using spaces in file names. It complicates things further down the line. If you must have separation between "fields" in the file names, use underscores.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply