September 28, 2009 at 8:57 am
I'm having an issue dealing with the File System Task. I need to create a log file in this task, but the filename needs to include the date/time at runtime: ex. FileName200909281058.log. How do I specify a dynamic filename (or can I?). Can someone please help?
September 28, 2009 at 10:07 am
You can should be able to use expressions in the connection string parameters for the source and destination connectors. You will want to create variables that you manipulate either through Exec SQL Task or a Script task (or any other way you can think of)..
CEWII
September 28, 2009 at 12:06 pm
It appears I can't create a file using the File System task. Seems odd that you can create a directory, but not a file. Does anyone know which task I should use to create a file in SSIS?
September 28, 2009 at 12:12 pm
What kind of a file?
CEWII
September 28, 2009 at 12:19 pm
An empty text file.
September 28, 2009 at 12:43 pm
Use the System.IO class in a Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO
Public Class ScriptMain
Public Sub Main()
Dim f As File
f.Create(Dts.Variables("FilePath").Value.ToString & "\EmptyTextFile" & Now.ToString("yyyyMMddhhmm") & ".txt")
f = Nothing
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
In this example, I have a variable named "FilePath". For this to work, you'll need to add the variable name to the ReadOnlyVariables section of the Script tab of the Script Task editor.
September 28, 2009 at 12:53 pm
That should work..
CEWII
September 28, 2009 at 12:56 pm
It doesn't seem to work. I get this error:
Error: Failed to lock variable "FilePath" for read/write access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".
September 28, 2009 at 1:17 pm
OK, I finally got it to work. I had add the variable to the Variables list as well.
Thanks for the help!
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply