File System Task issue

  • 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?

  • 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

  • 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?

  • What kind of a file?

    CEWII

  • An empty text file.

  • 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.

  • That should work..

    CEWII

  • 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.".

  • 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