[Execute SQL Task] Error: Executing the query "DECLARE_@XMLA nvarchar(3000) ,__@DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,

Hi
DECLARE @XMLA nvarchar(3000)
, @DateSerial nvarchar(35);
-- Change date to format YYYYMMDDHHMMSS
SET @DateSerial = CAST(GETDATE() AS DATE);
--SELECT @DateSerial
Set @XMLA = 
N' <Batch xmlns="http://schemas.microsoft.com/analysis services/2003/engine">
 <ErrorConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200"
xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200">
<KeyErrorLimit>-1</KeyErrorLimit>
<KeyNotFound>IgnoreError</KeyNotFound>
<NullKeyNotAllowed>IgnoreError</NullKeyNotAllowed>
 </ErrorConfiguration>
 <Parallel>
<Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2"
xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200"
xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
 <Object>
 <DatabaseID>MultidimensionalProject5</DatabaseID>
 <CubeID>giri</CubeID>
 <MeasureGroupID>Fact Internet Sales</MeasureGroupID>
 </Object>
 <Type>ProcessFull</Type>
 <WriteBackTableCreation>UseExisting</WriteBackTableCreation>
 </Process>
  </Parallel>
</Batch>';
EXEC (@XMLA) At SHALL-PCAdventureWorksDw ;
 iam executive the    query when iam getting below error.
  [Execute SQL Task] Error: Executing the query "DECLARE
@XMLA nvarchar(3000)
, @DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set
correctly, or connection not established correctly. 
 how to solve this error;
 please help me

What are you trying to do? What sort of data source is  SHALL-PCAdventureWorksDw?
When you use EXEC() AT, I would execpt to see an SQL string to be passed to EXEC(), but you are passing an XML string????
If you explain why you think this would work in the first place, maybe we can help you.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • : "Invalid object name '#Temp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

     Hi   .
        I was creating the  pass the values t in temp tables  though s sis package vs2012 .
      First I was taken on executive SQL TASK.
     IN EXCUTIVE SQL TASK  . I was write the stored proce:
    Sp;
    reate  procedure  USP_GETEMP2333
    AS
    begin
    Select  eid,ename,dept,salary from emp
    end;
    create table #temp(eid int,ename varchar(20),dept varchar(20),salary int)
      insert into #temp
       exec USP_GETMP02333
       go.
     It was executive correctly.
     I was taken another sequence container. In the sequence container iam creating one   executive  sql
    In 2<sup>nd</sup> excutive sql task: sql statements is
    if object_id('emp_fact_sal') is not null
     drop table emp_fact_sal
    select eid,ename as emp_name,sal_bar=
    case when salary<=5000 then 'l'
    when salary >5000 and salary<=7000 then 'm'
    else
    'h'
    end
    into emp_fact_sal from #temp.
     and one falt flies  it was taken to designation .
     iam changing  all  connection properties:
     in oldeb connection:
    in excutive sal task properties .
    delay validation is true,
    and retain connection maner is also true,
    and package mode is 64 bit is false.
     But iwas excutive in 2<sup>nd</sup> excutive ql task .
    Iam getting this type of errors,
                    [Execute SQL Task] Error: Executing the query " if object_id('emp_fact_sal') is not null
     drop ta..." failed with the following error: "Invalid object name '#Temp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
    correctly.
     Please help me

    Arthur suggestion works but you shouldnt even be doing this on a SQL Task.
    Use a data flow task. You'll have better control over the data that is being transfered and get better performance because no staging table will be used.
    Just because there are clouds in the sky it doesn't mean it isn't blue. But someone will come and argue that in addition to clouds, birds, airplanes, pollution, sunsets, daltonism and nuclear bombs, all adding different colours to the sky, this
    is an undocumented behavior and should not be relied upon.

  • "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly

    Hi,
    I have a SSIS package named FlushFeed4Data that copy data from a table named TableA in a database named DatabaseA located on SQL server 2005 named SQL2005 to another table named Table B in a database named DatabaseB located on a server 2012 named SQL2012.
    The server SQL2005 is setup like a linked server in the server 2012. My package runs smootly: first it removes all old records in SQL2012.DatabaseB.TableB & then copy all records from SQL2005.DatabaseA.TableA  to SQL2012.DatabaseB.TableB to without
    any error message. It runs well both when I ran debugging in SQL Server Data Tools (Microsoft Visual Studio) & when I executed this package in SSIS of server SQL2012. However when I use a job named FlushFeed4Data to run this package, I've got error message:
    Executed as user NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility Version 11.0.5058.0 for 64 bitCopyright (C) Microsoft Corporation. Code: 0xC002F210. Source: Insert Data Execute SQL Task. Dexcription: Executing the query "Insert
    Into SQL2012.B.[dbo].TableB ..." failed with the following error: "Login failed for user '[MyCompanyDomainName]\SQL2012$' ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not
    set correctly, or connection not established correctly. End Error DTExec: The package execution returned DTSER_FAILURE (1) ... The package execution failed. The step failed.
    Please help!
    Thanks
    Edward

    Hi Athur,
    Thanks so much for your reply. I'd really appreciate about that. Following the article given by your link, I got error message when trying to create proxy
    sg 14529, Level 16, State 1, Procedure sp_add_proxy, Line 45
    Proxy "MyCompanyDomainName\SSISProxyDemoUser" is not a valid Windows user.
    USE msdb
    --Create a proxy and use the same credential as created above 
    EXEC msdb.dbo.sp_add_proxy 
    @proxy_name = ', 
    @credential_name=N'SSISProxyCredentials', 
    @enabled=1 
    GO 
    So I have a question: Do I have to create a new user account that can access our network named 
    PS: Below are the steps I followed the article:
    --Script #1 - Creating a credential to be used by proxy
    USE MASTER
    GO 
    --Drop the credential if it is already existing 
    IF EXISTS (SELECT 1 FROM sys.credentials WHERE name = N'SSISProxyCredentials') 
    BEGIN 
    DROP CREDENTIAL [SSISProxyCredentials] 
    END 
    GO 
    CREATE CREDENTIAL [SSISProxyCredentials] 
    WITH IDENTITY = N'MyCompanyDomainName\SSISProxyDemoUser', 
    SECRET = N'abcd@0987' 
    GO
    --Script #2 - Creating a proxy account 
    USE msdb
    GO 
    --Drop the proxy if it is already existing 
    IF EXISTS (SELECT 1 FROM msdb.dbo.sysproxies WHERE name = N'SSISProxyDemo') 
    BEGIN 
    EXEC dbo.sp_delete_proxy 
    @proxy_name = N'SSISProxyDemo' 
    END 
    GO 
    and the rest of the script 2 hasn't been proceeded due to error:
    --Create a proxy and use the same credential as created above 
    EXEC msdb.dbo.sp_add_proxy 
    @proxy_name = N'SSISProxyDemo', 
    @credential_name=N'SSISProxyCredentials', 
    @enabled=1 
    GO 
    --To enable or disable you can use this command 
    EXEC msdb.dbo.sp_update_proxy 
    @proxy_name = N'SSISProxyDemo', 
    @enabled = 1 --@enabled
    = 0 
    GO
    Please advise me!
    Thanks,Edward

  • MFL: The dependency is not configured in schema resource. Possible reason one or more import/include is not set   correctly.

    HI Friends,
    I have a created a MFL to transform XML to Non XML format. When am generating a XSD out of this MFL am getting this Error:
    The dependency is not configured in schema resource. Possible reason one or more import/include is not set
    correctly.
    Here is the snippet of the XSD:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns="http://www.w3.org/2001/XMLSchema"
              targetNamespace=""
              xmlns:mfl="http://www.bea.com/mfl"
              elementFormDefault="qualified">
        <xsd:import namespace="http://www.bea.com/mfl"/>........
    Later Part i have searched for mfl.xsd in com.bea.wli.core.mflengine_1.x.x.x.jar in my.........../Oracle_OSB1/modules  and imorted this XSD into my eclipse workspace.
    Then i added the schemalocation attribute to the Import element. which looks something like below:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns="http://www.w3.org/2001/XMLSchema"
              targetNamespace=""
              xmlns:mfl="http://www.bea.com/mfl"
              elementFormDefault="qualified">
        <xsd:import namespace="http://www.bea.com/mfl" schemaLocation="../../mfl.xsd" />......
    After doing these changes also am getting the same error... can anyone help me out of this????

    Hi Arun,
    Also in SB console we can refer xsds from other projects but again OEPE doesnt seem to support that we will have to make duplicate copies of the resources in each project.It is not like that if you are using OEPE then you can not refer resources from other projects. Just what you need to do is that give relative path of the resource which is there in the file system. It does not matter that to which project it belongs. Yes, now with OEPE, you have to do this manually.
    Regards,
    Anuj

  • [Execute SQL Task] Error: Executing the query failed with error: "The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION."

    I have an package with source , data flow and destination to execute on begin and commit.
    in the below i have just used for questioning purpose with diagram removing my Data Flow task explaining my problem
    on execution, i get error as
    [Execute SQL Task] Error: Executing the query "COMMIT TRAN DimCompanyCode" failed with the following error: "The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.". Possible failure reasons: Problems with the query, "ResultSet"
    property not set correctly, parameters not set correctly, or connection not established correctly.
    as mentioned , i have checked the ResultSet, parameters , connection establish.. all are fine.
    Kindly advice on what has to be done.
    ShanmugaRaj

    To avoid this error, the RetainSameConnection property should set to 'True' for the Connection Manager - Application_DB.
    Narsimha

  • Execute SQL Task - FOR XML PATH query error

    I have the following query
    SELECT pl.Id,
    pl.StartTime,
    pl.EndTime,
    pl.PackageName,
    pl.Computer,
    pl.Operator,
    CASE WHEN (CHARINDEX('stack trace', pl.ErrorDescription) > 0) Then
        SUBSTRING(pl.ErrorDescription, 0, CHARINDEX('stack trace', pl.ErrorDescription))
        ELSE
        pl.ErrorDescription
        END as ErrorDescription
    ISNULL(ErrorFile,'') as ErrorFile,
    'Not Applicable' as SourceSystem
    FROM etl.PackageLog as pl
    WHERE pl.Processed = 0
    ORDER BY pl.StartTime, pl.PackageName
    FOR XML PATH('Row'), ROOT(N'FieldingCounts')
    in a Execute SQL Task and i get the following error:
    [Execute SQL Task] Error: Executing the query "SELECT pl.Id,
    pl.StartTime,
    pl.EndTime,
    pl.Package..." failed with the following error: "An invalid character was found in text content.
    ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    The query execute without problem in database and in the ssis package doens't run because of the column
    CASE WHEN (CHARINDEX('stack trace', pl.ErrorDescription) > 0) Then
        SUBSTRING(pl.ErrorDescription, 0, CHARINDEX('stack trace', pl.ErrorDescription))
        ELSE
        pl.ErrorDescription
        END as ErrorDescription
    Any help to overcome the problem?
    Thanks

    Hi,
    It looks like that you must be trying to set the result of the query to some variable from the Execute SQL Task. If yes, make sure that the target variable is of the correct data type where XML string  can fit into. Considering that in SSIS, we have
    some limit for XML strings.
    Please let me know if it doesn't help.
    Thanks,
    Nimit

  • Passing the same input parameter twise in execute sql task

    Hi All, I want to insert some values to 3 different tables in sql server. Execute sql task is used to populate three tables. Here is the sql statement.
    DECLARE @Dt AS DATE
    SET @Dt = ?
    INSERT INTO TABLE1 SELECT ?, COL2, COL3 FROM TABLE_A
    INSERT INTO TABLE2 SELECT ?, COL2, COL3 FROM TABLE_B
    Input parameter is mapped as follows :
    Variable name : User::EffectiveDate
    Direction : Input Data Type :
    Date Parameter name :0
    Parameter size :-1
    User::EffectiveDate is datetime variable.
    When the package is executed, it throws an error.
    [Execute SQL Task] Error: Executing the query " " failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems
    with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. I am not sure what I am doing wrong here. If anyone could point me to the right direction, I really appreciate.
    Thanks
    shamen

    To expand on the other answers.
    Your SQL command
    DECLARE @Dt AS DATE
    SET @Dt = ?
    INSERT INTO TABLE1 SELECT ?, COL2, COL3 FROM TABLE_A
    INSERT INTO TABLE2 SELECT ?, COL2, COL3 FROM TABLE_B
    It using 3 input variables.  I assume you didn't pass 3 variables and you want @DT to be column 1 in each.  In that case you would use:
    DECLARE @Dt AS DATE
    SET @Dt = ?
    INSERT INTO TABLE1 SELECT @Dt, COL2, COL3 FROM TABLE_A
    INSERT INTO TABLE2 SELECT @Dt, COL2, COL3 FROM TABLE_B

  • Execute SQL Task Error

    I am using the following query in Execute SQL Task
    SELECT CASE(SELECT COUNT(*) FROM STG_APJ_APIW_DETAILS
    WHERE source_filename = ?
    AND lTRIM(RTRIM([BILLING DATE])) <> '') WHEN 0 THEN (SELECT CONVERT(VARCHAR(8), GETDATE(), 112) AS [YYYYMMDD])
    ELSE
    (SELECT TOP 1 [BILLING DATE] FROM STG_APJ_APIW_DETAILS
    WHERE source_filename = ?
    AND lTRIM(RTRIM([BILLING DATE])) <> '')
    END
    In parameter Mapping i have created two parameters and in result set i choose my variable.
    Result set property is Single Row.
    Following is the error message i received,
    [Execute SQL Task] Error: Executing the query "SELECT CASE(SELECT COUNT(*) FROM STG_APJ_APIW_DETA..." failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems
    with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Sarvan

    I cant see where you've named resultset. try like below to make sure resultset has the name used in resultset tab
    SELECT CASE(SELECT COUNT(*) FROM STG_APJ_APIW_DETAILS
    WHERE source_filename = ?
    AND lTRIM(RTRIM([BILLING DATE])) <> '') WHEN 0 THEN (SELECT CONVERT(VARCHAR(8), GETDATE(), 112))
    ELSE
    (SELECT TOP 1 [BILLING DATE] FROM STG_APJ_APIW_DETAILS
    WHERE source_filename = ?
    AND lTRIM(RTRIM([BILLING DATE])) <> '')
    END AS [Billing Date]
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Execute SQL Task fails when specific column names are mentioned in Excel Query

    Hi,
    I have a requirement for extracting Excel data with thespecific column order. So instead of using the below query,
    Select * From [Sheet1$A1:ZZ1]
    I use the below one,
    Select col1,
    col2,
    col91
    From [CRM$A1:ZZ1]
    So I have totally 91 columns.
    I don't face any issues when i use the before query. i.e. direct select * from sheet1
    But when i specify column names and do a select from the sheet it throws error as below,
    [Execute SQL Task] Error: Executing the query "Select
    [Col1] 
    From [Sheet1$..." failed with the following error: "No value given for one or more required parameters.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not
    set correctly, or connection not established correctly.
    I just need to retrieve the column name alone and not any of the values to it. So when i do simple select * it gives the column names in the order of what it is been with the excel. But i do want it to be sorted in alphabetically and to retrieve the column
    names. 
    I am not getting any proper solution for this for past 1 and a half days. May anyone of you please help me get it sorted? - Thank you!
    --------------------------- Radhai Krish | Golden Age is no more far | --------------------------

    Please use something like below:
    SELECT F1 AS Col1, F2 AS Col2, F3 AS Col3, ...
    FROM [Sheet1$A1:ZZ1]
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • SSIS custom execute sql task : Failed with error

    I am developing a custom SSIS task for running sql task. But it fails with error - I'm trying to set the resultsetbinding to be used by next task in workflow.
    Error: 0xC0014054 at CustomSSISTask: Failed to lock variable "User::id" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container
    during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".
    Error: 0xC002F210 at CustomSSISTask, Execute SQL Task: Executing the query "SELECT id FROM sysobjects WHERE name = 'sysrowsets..." failed with the following error: "Failed to lock variable "User::id" for read access with error 0xC0010001
    "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is
    not being created.".
    ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Warning: 0x80019002 at CustomSSISTask: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (3) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches
    the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
    Task failed: CustomSSISTask
    Here is the code sample I'm trying , 
            public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser,
                                                  IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
                MessageBox.Show("testing:");
                try
                    // Add the SQL Task
                    Package package = new Package();
                    package.Executables.Add("STOCK:SQLTask");
                    Microsoft.SqlServer.Dts.Runtime.Variable variable = package.Variables.Add("id", false, "User", 0);
                     // Get the task host wrapper
                    TaskHost taskHost = package.Executables[0] as TaskHost;
                    // Get the task object
                    ExecuteSQLTask task = taskHost.InnerObject as ExecuteSQLTask;
                    // Set core properties
                    task.Connection = connections[0].Name;
                    task.SqlStatementSource = "SELECT id FROM sysobjects WHERE name = 'sysrowsets'";
                    //task.SqlStatementSource =
                    //    "SELECT PersonID from [AmalgaSpeedTableData].[SpeedTable].[DimPerson] where PersonIntID  = '1'";
                    task.SqlStatementSourceType = SqlStatementSourceType.DirectInput;
                    // Add result set binding, map the id column to variable
                    IDTSResultBinding resultBinding = task.ResultSetBindings.Add();
                    //IDTSResultBinding resultBinding = task.ResultSetBindings.GetBinding(0);
                    resultBinding.ResultName = "variable";
                    resultBinding.DtsVariableName = variable.QualifiedName; //"User::id";
                    task.Execute(connections, variableDispenser, componentEvents, log, transaction);
                catch (Exception ex)
                    throw new ArgumentException(ex.Message);
                return DTSExecResult.Success;
    It doesnt throw any exception but custom task fails.
    Later I will be also using parametersetbindings to pass some input parameters to this task , since I'm stuck for out param - blocked moving ahead.
    Any help would be greatly appreciated.
    Thanks
    Sang

    Hi, could you check whether the following threads help:
    http://stackoverflow.com/questions/5787621/ssis-package-failed-to-locak-variable-for-read-access-with-error-0xc0010001
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/40ee7eff-5ec1-426f-a1a8-ab85b40b51aa/error-variable-can-not-be-found-while-executing-package-from-the-net-code?forum=sqlintegrationservices
    Regards, Leo

  • SSIS - Using Variables in Execute SQL Task Error

    The following query in my Execute SQL Task throws the following error when run - [Execute SQL Task] Error: Executing the query "SELECT @columnz = COALESCE(@columnz + ',[' + times..." failed with the following error: 
    "Must declare the scalar variable "@columnz".". Possible failure reasons: Problems with the query, 
    "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Query:
    drop table tmpNCPCNCDownstreamMaxUtilization3wks
    select node, max(utilization) as max_Utilization, DATE
    into tmpNCPCNCDownstreamMaxUtilization3wks
    from stage_ncpcncdownstream_temporal
    WHERE Date BETWEEN DATEADD(day, -20, GETDATE()) AND GETDATE() 
    group by node, date
    order by node
    go
    alter table tmpNCPCNCDownstreamMaxUtilization3wks add Timestamp varchar(50)
    go
    update tmpNCPCNCDownstreamMaxUtilization3wks
    set Timestamp = 'WeekOf_' + cast(left(Date, 11) as varchar)
    go
    --drop table tmpNCPCNC_DownstreamNodeUtilizationMaxPivot
    --go
    declare @columnz varchar (8000)
    go
    SELECT @columnz = COALESCE(@columnz + ',[' + timestamp + ']','[' + timestamp+ ']')
    FROM tmpNCPCNCDownstreamMaxUtilization3wks group by timestamp order by timestamp
    go
    --pivot contents in @columns
    declare @query varchar(8000)
    SET @query ='select * into tmpNCPCNC_DownstreamNodeUtilizationMaxPivot from 
    (select node, timestamp, Max_Utilization from tmpNCPCNCDownstreamMaxUtilization3wks)a
    pivot
    sum(max_Utilization) for timestamp in('+ @columnz +')
    )as p'
    execute (@query)
    --empty contents from NCPCNCDownstreamMaxUtilization3wks
    update tmpNCPCNCDownstreamMaxUtilization3wks
    set timestamp =''
    truncate table tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    --load to table to be joined to Node feature class
    insert into tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    (Node, TwoWeeksAgo, PreviousWeek, CurrentWeek)
    select * from tmpNCPCNC_DownstreamNodeUtilizationMaxPivot
    --calculate average utilization for all values in each record
    update tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    set average = (coalesce(twoweeksago, 0) + coalesce(previousweek, 0) + coalesce(currentweek, 0))/3
    from tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    Scott

    Issue is with variable @columnz.
    Scope of variables is only limited to the batch and if batch is over Variable is no more accessible.
    Reproduce Steps: 
    DECLARE @columnz int = 0
    Go --Scope of @columnz ends here
    SELECT @columnz -- Ends up with error
    So you have to remove GO keyword. I have commented 2 of them in below:
    DROP TABLE tmpNCPCNCDownstreamMaxUtilization3wks
    SELECT node
    ,max(utilization) AS max_Utilization
    ,DATE
    INTO tmpNCPCNCDownstreamMaxUtilization3wks
    FROM stage_ncpcncdownstream_temporal
    WHERE DATE BETWEEN DATEADD(day, - 20, GETDATE())
    AND GETDATE()
    GROUP BY node
    ,DATE
    ORDER BY node
    GO
    ALTER TABLE tmpNCPCNCDownstreamMaxUtilization3wks ADD TIMESTAMP VARCHAR(50)
    GO
    UPDATE tmpNCPCNCDownstreamMaxUtilization3wks
    SET TIMESTAMP = 'WeekOf_' + cast(left(DATE, 11) AS VARCHAR)
    GO
    --drop table tmpNCPCNC_DownstreamNodeUtilizationMaxPivot
    --go
    DECLARE @columnz VARCHAR(8000)
    --GO
    SELECT @columnz = COALESCE(@columnz + ',[' + TIMESTAMP + ']', '[' + TIMESTAMP + ']')
    FROM tmpNCPCNCDownstreamMaxUtilization3wks
    GROUP BY TIMESTAMP
    ORDER BY TIMESTAMP
    --GO
    --pivot contents in @columns
    DECLARE @query VARCHAR(8000)
    SET @query = 'select * into tmpNCPCNC_DownstreamNodeUtilizationMaxPivot from
    (select node, timestamp, Max_Utilization from tmpNCPCNCDownstreamMaxUtilization3wks)a
    pivot
    sum(max_Utilization) for timestamp in(' + @columnz + ')
    )as p'
    EXECUTE (@query)
    --empty contents from NCPCNCDownstreamMaxUtilization3wks
    UPDATE tmpNCPCNCDownstreamMaxUtilization3wks
    SET TIMESTAMP = ''
    TRUNCATE TABLE tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    --load to table to be joined to Node feature class
    INSERT INTO tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week (
    Node
    ,TwoWeeksAgo
    ,PreviousWeek
    ,CurrentWeek
    SELECT *
    FROM tmpNCPCNC_DownstreamNodeUtilizationMaxPivot
    --calculate average utilization for all values in each record
    UPDATE tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    SET average = (coalesce(twoweeksago, 0) + coalesce(previousweek, 0) + coalesce(currentweek, 0)) / 3
    FROM tmpNCPCNC_MaxDownstreamNodeUtilzationChart3Week
    -Vaibhav Chaudhari

  • Execute SQl Task Error SSIS Package

    Hi all,
    I`m using for each loop container in my package to grab the file name from the source path. I have created 2 vairables
    FilePath and SourceFolder
    I`m using execute sql task inside the container and this is my query
    Insert into [dbo].[DCA_FF_TEST] (File_Name,File_Date) SELECT File_name = ?,
    File_Date = GetDate()
    Please not the Table I am trying to insert has more columns but at this stage I dont need them.
    When i execute the task I get an error
    [Execute SQL Task] Error: Executing the query "
    INSERT INTO   [dbo].[DCA_FF_TEST] ([File_Name],[F..." failed with the following error: "The statement has been terminated.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters
    not set correctly, or connection not established correctly.
    Can someone point me in the right direction? Am I missing anything?
    Resultset property Set to None
    Parameter Mapping: Variablename: FilePath , Direction: Input, datatype : Varchar, Parametername: 0, ParameterSize: 100.
    I`ve checked the connection as well it works.
    FM

    Did you try
    Insert into  [dbo].[DCA_FF_TEST] (File_Name,File_Date)
    SELECT ?, GetDate()
    Or
    Insert into  [dbo].[DCA_FF_TEST] (File_Name,File_Date) VALUES (?, GetDate())
    A Fan of SSIS, SSRS and SSAS

  • Failed to create an IDataAdapter object. This provider may not be fully supported with the Execute SQL Task

    I executed a simple query inside an execute SQL task - 
    SELECT col1, col2
    from thetable
    where code = ?
    order by id asc
    Exec sql task - ADO.NET connection
    parameter "code" is an int32 in SSIS and int32 in parameter mapping of exec sql task.
    It works fine in SQL server, but in SSIS it causes the error - 
    [Execute SQL Task] Error: Executing the query "SELECT col1, col2
    from thet..." failed with the following error: "Failed to create an IDataAdapter object. This provider may not be fully supported with the Execute SQL Task. Error message 'Incorrect syntax near '?'.'.". Possible failure reasons: Problems with
    the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    How do I fix this error ? 

    Thanks. I think it was sqlclient. I changed it to OLEDB to avoid that issue. Btw, what is this "provider" ?
    Hi blastoSO,
    To check which provider is used by the current ADO.NET Connection Manager, you can open the “Configure ADO.NET Connection Manager” window, and check the “Managed Provider” option of each Data connection.
    In an Execute SQL Task, if the managed provider is “System.Data.SqlClient”, we should use the rule for the ADO.NET connection type in the following table. If the managed provider is “System.Data.Oledb” or “System.Data.Odbc”, it actually uses the OLE DB provider
    or ODBC provider, so we should use the rule for the OLE DB or OBC rule in the following table:
    Reference:
    http://technet.microsoft.com/en-us/library/cc280502.aspx
    Regards,
    Mike Yin
    TechNet Community Support

  • Execute SQL Task Error: Resultset Property

    Looking to find help on resolving the below noted error
    Full Error Text: "The statement has been terminated.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    We are creating new packages in SQL2012 from older packages from SQL2008.  My package has several tasks, but 3 of the 18 are failing.  The first of which is the above noted error, from the following script - Any insight to resolving this error
    would be most helpful.  Thanks in advance
    NOTE:  ResultsetType = None
    Regards,
    Newbie SSIS
    Task - UPDATE BUSINESS_GROUP_ORG INFO
     UPDATE SOLD_FROM ORGANIZATION_ID NAME
    UPDATE ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG
      SET BUSINESS_GROUP_ID = APPS_HR_ALL_ORGANIZATION_UNITS.BUSINESS_GROUP_ID,
          ORG_ID_NAME = APPS_HR_ALL_ORGANIZATION_UNITS.NAME
      FROM APPS_HR_ALL_ORGANIZATION_UNITS
      WHERE
          ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG.SOLD_FROM_ORG_ID = APPS_HR_ALL_ORGANIZATION_UNITS.ORGANIZATION_ID
     UPDATE BUSINESS_GROUP_NAME
    UPDATE ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG
      SET BUS_GROUP_NAME = APPS_HR_ALL_ORGANIZATION_UNITS.NAME
      FROM APPS_HR_ALL_ORGANIZATION_UNITS
      WHERE
          ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG.BUSINESS_GROUP_ID = APPS_HR_ALL_ORGANIZATION_UNITS.ORGANIZATION_ID
     UPDATE SHIP_FROM_ORGANIZATION_NAME
    UPDATE ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG
      SET SHIP_FROM_ORG_NAME = APPS_HR_ALL_ORGANIZATION_UNITS.NAME
      FROM APPS_HR_ALL_ORGANIZATION_UNITS
      WHERE
          ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG.SHIP_FROM_ORG_ID = APPS_HR_ALL_ORGANIZATION_UNITS.ORGANIZATION_ID

    Your UPDATE statement doesn't look right. In all the 3 UPDATE statements, you are Updating table
    ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG but that table doesn't exist in the FROM clause i.e. the FROM clause has a different table
    APPS_HR_ALL_ORGANIZATION_UNITS. Looks like you are missing a JOIN between those 2 tables.
    Can you try this ?
    UPDATE SOLD_FROM ORGANIZATION_ID NAME
    UPDATE ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG
    SET BUSINESS_GROUP_ID = APPS_HR_ALL_ORGANIZATION_UNITS.BUSINESS_GROUP_ID,
    ORG_ID_NAME = APPS_HR_ALL_ORGANIZATION_UNITS.NAME
    FROM APPS_HR_ALL_ORGANIZATION_UNITS
    , ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG --I've only added this
    WHERE
    ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG.SOLD_FROM_ORG_ID = APPS_HR_ALL_ORGANIZATION_UNITS.ORGANIZATION_ID
    UPDATE BUSINESS_GROUP_NAME
    UPDATE ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG
    SET BUS_GROUP_NAME = APPS_HR_ALL_ORGANIZATION_UNITS.NAME
    FROM APPS_HR_ALL_ORGANIZATION_UNITS
    , ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG --I've only added this
    WHERE
    ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG.BUSINESS_GROUP_ID = APPS_HR_ALL_ORGANIZATION_UNITS.ORGANIZATION_ID
    UPDATE SHIP_FROM_ORGANIZATION_NAME
    UPDATE ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG
    SET SHIP_FROM_ORG_NAME = APPS_HR_ALL_ORGANIZATION_UNITS.NAME
    FROM APPS_HR_ALL_ORGANIZATION_UNITS
    , ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG --I've only added this
    WHERE
    ORA_C_OE_ORDER_LINES_ALL_ACTUALS_ADJUSTMENTS_STG.SHIP_FROM_ORG_ID = APPS_HR_ALL_ORGANIZATION_UNITS.ORGANIZATION_ID
    Narsimha

  • Using Union in Execute SQL Task

    I am using the following SQL statement in an Excute SQL Task:
    declare @RespAreaSubAreaID int, @UserLevelID int, @SubmittedByUserID int, @RespAreaID int, @SubAreaID int
    Set @RespAreaSubAreaID = ?
    Set @SubmittedByUserID = ?
    Set @UserLevelID = ?
    set @RespAreaID = ?
    set @SubAreaID = ?
    select users.User_EmailAddress + ';' As CC
    from users inner join UserLevelsNotificationFrequencys on users.user_Id = UserLevelsNotificationFrequencys.User_id
    where UserLevelID = @UserLevelID and RespAreaSubAreaID = @RespAreaSubAreaID and (NotificationFrequencyID = 4 and users.user_id <> @SubmittedByUserID)
    union
    select users.User_EmailAddress + ',' As CC
    from users inner join UserLevelsNotificationFrequencys on users.user_Id = UserLevelsNotificationFrequencys.User_id
    where UserLevelID = @UserLevelID and RespAreaSubAreaID = @RespAreaSubAreaID and (NotificationFrequencyID = 1)
     I have my parameter mapped correctly. My results set is set to xml because I want it all in one string to use as a variable named User:CC. On the Result Set tab the result name is 0 and the variable name is User:CC. When I run my package I am getting
    the error below. Can I not do a union query in the execute SQL task? I tried to not declare anything and just map to each of the variables that I am passing in the order that they are needed but that didn't work either. Thanks in advance for your help in this
    matter.
     [Execute SQL Task] Error: Executing the query "declare @RespAreaSubAreaID int, @NotificationID
    in..." failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection
    not established correctly.
    Reach for the unknown!

    Thank you for your reply but I am not using the Data Flow. All my work is happening on the Control Flow. I am looping through a set of records and emailing them to the correct
    people. Setting my result set to XML worked for the To Line (See my earlier post Execute SQL task for Email ToLine using COALESCE and two variables) and now I am working on the CC line which is more complicated because it uses a union statement.
    Reach for the unknown!

Maybe you are looking for

  • Cannot print to Brother HL-2270DW after loading mavericks

    Cannot print to Brother HL-2270DW after loading mavericks

  • No audio when using headphones.

    Has anyone had issues when using headphones with the android maxx?

  • Dial-up Connection Programme...

    Is it possible to write a dial-up connection programme in Java? It would also be interesting to know whether there exist some specs on the modem api. thank you luka

  • Cash flow statement (direct)

    Hi experts, I'm using SAP ECC6 and I'm aware of SAP has provided "Liquidity Planner" process. Anyone knows where to get the step by step configuration on this ? I heard that Russia has a model in standard SAP. Any example of configuration documentati

  • Website search widget recommendation?

    I'd like the ability to add a search function like on the top right of this forum. I spent time attempting to find a decent one using search engines, but haven't found anything good yet. Any recommendations on one that is iWeb friendly? Thanks! Dave