SSIS -using field values in file name

  • I want to create a file name that selects a field from a table and uses that in the name of a flat file.

    Example:

    Create table dbo.daily_alert (

    Start_date varchar(50) )

    insert into dbo.daily_alert (20080622)

    Now want to set the value of a user defined SSIS variable with that field, something like:

    @user::my_date = (select start_date from dbo.daily_alert)

    Then use that user::my_date in my flat file connection property, something like,

    @user::my_date+".txt"

    I know how to create user defined variable and create the connection property, just don't know how to set variable.

    Thank you,

    Sharon

  • You can do this iby setting Expression for Flat File connection. Select the flat file ->Select Expression (from properlty window) - >Property expression editor - >connection string> and then fill in your expression

    @[User::mydate] + ".txt"

    This artile might be helpful for you

    http://www.mssqltips.com/tip.asp?tip=1084

    [Edit] - I think i misunderstood your question, i think you want to know how to set the result of sql query to a variable. if thats the case then you can do it by first seting the ResultSet to Singlerow (make sure that your query returns one row) and then go to the resultset page and add your variable here. Set the resultset name = 0 for OLEDB connection

    http://msdn.microsoft.com/en-us/library/cc280492.aspx

  • Yes, I think that I need to do this in Execute Sql Task.

    Thank you.

    Sharon

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

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