How to setup the file path value without change the code in dev & test & Prod

  • Hello All,

    in my ssis package i have a script task and data flow task

    script task work is to open text file and make some changes to the data in file and it creates a new file with changed data

    then data flow task reads data from file and write to sql table

    example of script

    Dim path As String = "C:\Feeds\SSIS\Input\mytextfile.txt"

    Dim sr As StreamReader = New StreamReader(path)

    Dim fileCreateDate As Date = File.GetCreationTime(path)

    Dts.Variables.Item("User::FileCreatedDate").Value = fileCreateDate

    line = sr.ReadLine()

    If (line Is Nothing) Then Exit Do

    If (Not (line.StartsWith(""""))) Then Continue Do

    ...............

    ...........

    ........

    now what i am trying here is, in test environment the path is different, and also path is different in production

    instead of changing every place the paths manually,. how can i set it up with variables so that i just change variables values when i configure ssis package in sql server jobs

    or is there any other good ways to overcome this problem

    please suggest me...

    Thanks in advance

    asita

  • Use a config file to set up a package variable. Pass the package variable to the script task. Check out this link.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply