SQL Server Performance

Save a Variable From contents loaded from a table

Discussion in 'SQL Server 2005 Integration Services' started by tthomasol, Apr 11, 2008.

  1. tthomasol New Member

    I'm new to SSIS and I'm trying to load a variable from a table. Can anyone tell me how to dot that?
    I want to SELECT TOP 1 VAL FROM TBL WHERE CONDITION = SOMETHING
    and Store that into a Variable SystemVar1
    Then use that variable in another query later on.
    Do I need to use a script?
    If so can you guide me to some documentation that will give me a good example, I have not done any scripting in SSIS yet.
    Thanks,
    Tim
  2. Madhivanan Moderator

    SELECT TOP 1 @systemvar1=VAL FROM TBL WHERE CONDITION = SOMETHING
    Now you can use @systemvar1 it later in the code
  3. tthomasol New Member

    <P mce_keep="true">Should this be placed inside an OLE DB Source ?</P><P mce_keep="true">That's where I'm trying to put it and I'm getting a parsing error.</P><P mce_keep="true"><IMG title="My Settings" style="WIDTH: 720px; HEIGHT: 636px" height=636 alt="My Settings" src="http://i97.photobucket.com/albums/l213/tthomasol/SSIS.gif" width=720 mce_src="http://i97.photobucket.com/albums/l213/tthomasol/SSIS.gif"></P><P mce_keep="true">&nbsp;</P>
  4. jagblue New Member

    Hi What you can do is create one more variable which will create your SQL statement dynamically using your system variable
    After that use this new veriable as you SQL Command for ola DB Source.Change your Data Access mode to Sql Command From Veriable
    Thank You
  5. tthomasol New Member

    Thanks for the response,
    I'm not sure I follow you. My question is, how do I assign a value to a variable using the contents from a table that I have queried. From my understanding of your solution I still have to assign a value to a variable from a table, and that is what I don't know how to do. I want that variable to be used anywhere else in the package that I need it. I'm sorry if I don't understand your response, I am very new to SSIS and this seems like it should be a very elementary thing but I can't seem to find an easy answer. I think the Madhivanan's answer above is what I'm looking for but I don't know where I'm supposed to put the statement.
  6. jagblue New Member

Share This Page