execute sql task object, how to use global variable inside

  • Hi,

    i used an execute sql task object in my dts.  i read something about dynamic properties and i incorporated it in my dts so that if i need to transfer it to another server, all i need to do is edit the ini file and everything will work fine.

    i just want to know how can i use a global variable in my execute sql task object. 

    thanks

    ann

     

  • Hi,

    In execute sql task either you need to make a query or execute stored procedures. In both cases you can use global variables for parameters. like in a sql query you can use something like

    SELECT column_name

    FROM table_name

    WHERE some_column_name = ?

    Then click on the parameters tab and click on input global variables and the select the one you want to use.If you have many parameters in your query then you need to add them in the order they occur in your query(Likewise you can use global variables to store the result of your query as well).

    Hope this helps

    Urvashi

  • Hi!

    The fact of using a Global variable in a SQL Task is nothing to be with using Dynamic Properties Task. It's completely independente.

    To use a Global Variable in a SQL Task, you just need to put the "?" caracter in the positions (inside SQL statement) you whant to substitute by the global variables. Then press the parameters button, and associate the correct Global Variable to each "?".

     

    Vitor

  • I'm using this today also.  This worked, so thanks!

  • my sql statement is below and after typing them and pressing on the parameters button, i am getting an error: syntax error or acces violation.  then i can't get access to the parameters screen. 

    exec master.dbo.xp_sendmail 'email address',

    'Please find attached excel file containing the current movements for AWA',

    '',

    ?,

    '',

    '',

    'subject line'

    any ideas?

    ann

  • got it.  answer is shown in the link below:

    http://www.sqldts.com/default.aspx?234

Viewing 6 posts - 1 through 5 (of 5 total)

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