SQL Task error using Parameters

  • I’m getting the following error from an Execute SQL Task:

     

    Error: 0xC002F210 at Get PkgExecKey, Execute SQL Task: Executing the query "INSERT INTO dbo.Dim_Audit_Pkg_Execution

           (Pkg_Name)

    Values (@Pkg_Name)" failed with the following error: "Must declare the scalar variable "@Pkg_Name".". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    Task failed: Get PkgExecKey

     

    The SQL code is:

    INSERT INTO dbo.Dim_Audit_Pkg_Execution

                (Pkg_Name)

    Values (@Pkg_Name)

     

    The Parameter Mappings are:

    Variable:                       System:: PackageName

    Direction:                      Input

    Data Type:                    varchar

    Parameter Name:           @Pkg_Name

     

    If I replace Values (@Pkg_Name) in the SQL Code with Values (‘Test’) … this works.

     

    What am I doing wrong when using the parameter?

     

    Cheers

  • try changing your SQLCode to:

    INSERT INTO dbo.Dim_Audit_Pkg_Execution

    (Pkg_Name)

    Values (?)

  • Yes ... of course.

    Thanks Wanderer

  • I am trying to achieve following insert in Execute SQL task which was working fine in past but right now it has started giving problem

    INSERT INTO Filter (CID, FilterId, UserName, Description, AppId, Definition) SELECT CID=?, FilterId, UserName, Description, AppId, Definition FROM Filter WHERE (CID = 0)

    OLEDB provider is used, parameter mapping with NextCID is configured correctly still this task fails with follwing error

    Error: 0xC002F210 at Execute SQL Task - Insert default Filter data to Client destination, Execute SQL Task: Executing the query "INSERT INTO Filter (CID, FilterId, UserName, Description, AppId, Definition) SELECT CID=?, FilterId, UserName, Description, AppId, Definition FROM Filter WHERE (CID = 0)" failed with the following error: "Syntax error or access violation". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

  • Have there been some changes to the package?

    Have you tried:

    INSERT INTO Filter (CID, FilterId, UserName, Description, AppId, Definition) SELECT ?, FilterId, UserName, Description, AppId, Definition FROM Filter WHERE (CID = 0)

    also, try:

    INSERT INTO Filter (CID, FilterId, UserName, Description, AppId, Definition) SELECT ? AS CID, FilterId, UserName, Description, AppId, Definition FROM Filter WHERE (CID = 0)

    As the error message says, check the ROWSET parm - has it been changed?

  • Is the CID mapped to LONG or NUMERIC. ..... it shud be LONG (if it is integer)

  • There are some changes happened in package but not on this Execute SQL task where suddenly problem started coming.

    Its mapped with Long. I have already tried following combinations but still problem is same

    INSERT INTO Filter (CID, FilterId, UserName, Description, AppId, Definition)

    SELECT ? as CID, FilterId, UserName, Description, AppId, Definition FROM Filter WHERE (CID = 0)

    or

    INSERT INTO Filter (CID, FilterId, UserName, Description, AppId, Definition)

    SELECT ? , FilterId, UserName, Description, AppId, Definition FROM Filter WHERE (CID = 0)

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

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