SQL Server Performance

Simple SSIS? - Use variable in sql statement....

Discussion in 'SQL Server 2005 Integration Services' started by sql_jr, Aug 21, 2008.

  1. sql_jr New Member

    I have successfully created a variable and able to populate it via query.
    Now I want to take that variable, and use it in a simple select statement. I'm having an awful time figuring this out, so please include steps...
    ie: Select * from table where col= mySSISvar. thx
  2. satya Moderator

  3. dineshasanka Moderator

    Ues a SQL command option and type folowoing query
    Select * from table where col= ?
    then map the variables
  4. rohit2900 Member

    Hi.... I'm new to SSIS packages....
    I'm facing a issue..... I've to modified a existing package and in that package in "Data Flow Task" in "OLE DB Source Editor" their is sql query already existing and working fine but in order to modify it in need to add new condition based on a newly created variable which will hold either 'T' or 'F' and on the basis of this variable I need to execute the query as if 'T' then the existing query and if 'F' then I've one more query which I need to add. Can any one suggest how should I implement this.
    below is the query.IF
    (VAR1 = 'T')BEGINSELECT .....
    FROM TABLE1
    WHERE COL1= ?END
    ELSE
    BEGIN
    SELECTCOL1,COL2....
    COUNT(*) AS COUNTER
    FROM TABLE2 T2, TABLE5 T5
    WHERE T1.COL = T5.COLWHERE T2.COL = ?
    GROUP BYT2
    ,COL1T2.COL2
    END
    If true the already existing query should be executed and the false one I need to add...but giving below error...
    Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" access mode, in which the entire SQL command is stored in a variable.
    ADDITIONAL INFORMATION: Syntx error, Permission Voilation, or other nonspecific error (Microsoft SQL Native Client)
    Thanks in Advance.

Share This Page