How to use a variable in SQL query

  • Hi All,

    I am new to SSIS. Currently I have a package in which source is Oracle database and I am using a SQL command to fetch the columns from database. In the SQL query Where clause for a particular column have been compared with hard coded IDs. Records corresponding to hard coded IDs are returned. Once data is returned its loaded to SQL Server DB. Right now package is working fine.

    Now what I am trying to achieve is instead of hard coding the values in SQL WHERE clause I want to fetch the values from SQL Server database table and want to do the comparison. Just to remind you, SQL query will run against Oracle DB.

    Currently in my package control flow I have Execute SQL Task(to truncate the the tables before data load) and Data Flow(loads data from Oracle to SQL Server).

    I am using SQL Server 2005. Please guide me.

  • What object type are you using for the query to Oracle? If it's an ODBC/OLE DB data source, the query can contain variables, which can be assigned values elsewhere in the package (perhaps through a For Each loop on a dataset of values).

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thank you very much for the reply.

    I am using OLE DB data source. Can you please tell me how to assign the variable in the query. Any link will help me a lot.

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

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