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

Last post 09-12-2008 7:47 AM by rohit2900. 3 replies.
Page 1 of 1 (4 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 08-21-2008 3:24 PM

    • sql_jr
    • Top 75 Contributor
    • Joined on 10-03-2006
    • NY USA
    • Posts 224

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

    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

  • 08-31-2008 12:58 PM In reply to

    • satya
    • Top 10 Contributor
    • Joined on 11-05-2002
    • United Kingdom
    • Posts 22,515
    • Microsoft MVP

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

    -Satya S K J

    SQL Server MVP



    Knowledge is Power, you will gain by sharing it. SSQA.net - Invisible contributions to the users & visible success in SQL Community.
  • 09-01-2008 4:44 AM In reply to

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

    Ues a SQL command option and type folowoing query

    Select * from table where col= ?

    then map the variables

     

    Contributing Editor, Writer & Forums Moderator http://www.SQL-Server-Performance.Com

    Visit my Blog at http://dineshasanka.spaces.live.com/

    View Dinesh Asanka's profile on LinkedIn
  • 09-12-2008 7:47 AM In reply to

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

    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')

    BEGIN

    SELECT .....

    FROM TABLE1

    WHERE COL1= ?

    END

    ELSE

    BEGIN

    SELECT

    COL1,

    COL2....

    COUNT(*) AS COUNTER

    FROM TABLE2 T2,  TABLE5 T5

    WHERE T1.COL = T5.COL

    WHERE T2.COL = ?

    GROUP BY

    T2,COL1

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

    Rohit Paliwal
    MCDBA
    View Rohit Paliwal's profile on LinkedIn
Page 1 of 1 (4 items)
Active Topics   My Discussions    Unanswered Posts


© 2000 - 2007 vDerivatives Limited All Rights Reserved.