Error using variable in sql - Statement

  • Hi!

    I've got a Execute SQL Task.

    I have a Parameter-Mapping on a global variable ("var_test"). Scope is on the whole package. I set the Mapping to

    Direction: INPUT

    Data Type: NVARCHAR

    Parameter: var_test2

    How can I use this value in sql Statement of this task?

    I thought in SQL 2000 DTS it was like:

    DECLARE @var_test3 VARCHAR(100)

    SET @var_test3 = (SELECT ?)

    INSERT INTO DTSSTATUS (FIELD) VALUES (@var_test3)

    But this won't work for me.

    Please help me.

    Thank you

    Chris

  • Chris,

    Assuming your variable is a single value, try the following:

    INSERT INTO DTSSTATUS (FIELD)

    (SELECT ?)

    And make sure the PARAMETER NAME value of the variable in the Parameter Mapping box is set to 0.

    Just an FYI on parameters in SSIS, you have to use integers in order of the variables' use in the PARAMETER NAME field starting with 0 for the first variable. Or at least that's the only way it's ever worked for me.

    If anyone else has different experiences in this, please let me know.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

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

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