How to use script task for my excute sql task

  • Hi ALL,

    I have the below sql script and need to use Execute SQL task in SSIS package to run this

    ----Script---

    declare @Status varchar(10), @ErrorMsg nvarchar(max)

    exec dbo.p_check_available 'NLD', @Status output

    If @Status = 'INVALID' or @Status is NULL

    begin

    select @ErrorMsg = 'Data Not available'

    insert into t_Log_Table

    (Status, Description, DateCre, UserCre)

    values

    ('INVALID',@ErrorMsg, GETDATE(), SUSER_SNAME())

    raiserror ( @ErrorMsg , 17, 127)

    return

    end

    ---end---

    Like this I have many SQL scripts in my package.

    I am declaring the @Status variable in Package level.Is that correct?

    I am new to SSIS Execute SQL task,Please help me on this.

  • Sorry,there is a mistake in my Topic: How to use Execute SQL task for my SQL Script 😉

  • Your SQL script will run as is so it is unclear what you are trying to accomplish. You mentioned you created a variable at the package level with the same name as a variable in your SQL script, but what is it that you wanted to happen with it?

    Best guess you are either wanting to map the value of the variable into the statement in the Execute SQL Task, or you want a variable value to be mapped from your SQL into the variable. Either way this article may be able to help explain how to do that. It depends on your what type of connection you're using, e.g. ADO.NET, OLE DB, etc:

    Map Query Parameters to Variables in an Execute SQL Task

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

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

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