Execute SQL Task: Cannot assign value to the variable
DECLARE
@PartitionDate varchar(8),
@Date int
SELECT
@PartitionDate = MAX(PartitionDate)
FROM PartitionLog (NOLOCK)
SELECT
@Date = MIN(DateKey)
FROM DimDate WHERE CAST(DateKey as varchar(8)) > @PartitionDate
IF NOT CONVERT(varchar(8),GETDATE(),112) = @PartitionDate
SELECT @PartitionDate = CAST(DateKey as varchar(8))
FROM DimDate (NOLOCK)
WHERE DateKey = @Date
SELECT @PartitionDate AS PartitionDate ,
'IISDW_' + @PartitionDate AS PartitionName
GO
I have the above SQL stmt in the excute SQL task and declared 2 variable "PartitionDate" and "PartitionName" in the Package, the RESULT SET I hav given as "Single Row" and when I run the ETL I get the error as
[Execute SQL Task] Error: An error occurred while assigning a value to variable "PartitionDate": "Exception from HRESULT: 0xC0015005".
Does your package variable datatype match the datatype of your parameter?
Is your Package variable assigned to the parameter in the task editor?
And does the parameter name in the task editor match the parameter names in your stored procedure?
Similar Messages
-
I am experiencing an unexplainable behavior with the Execute SQL Task control in SSIS 2012. The following is a description of how to simulate
the issue I will attempt to describe:
1. Create a package and add two variables User::varTest1 and User::varTest2 both of String type with default value of "Select GetDate()"
for each, have shown this to not matter as the same behavior occurs when using a fixed string value or empty string value.
2. Add a new Execute SQL Task to the control flow.
3. Configure an OLE DB connection.
4. Set SQLSourceType = "Direct Input"
5. Set the ResultSet property of the task to "Single Row"
6. In the ResultSet tab add two results as follows:
Result Name: returnvalue1, Variable Name: User::varTest1
Result Name: returnvalue2, Variable Name: User::varTest2
7. Set an expression for the SqlStatementSource property with a string value of "Select 'Test' returnvalue1, 'Testing' returnvalue2'"
The idea is that the source would be dynamically set in order to run a t-sql statement which would have dynamic values for database name
or object that would be created at runtime and then executed to set the user variable values from its resultset. Instead what occurs is that a DBNull error occurs.
I am not sure if anyone else has experienced this behavior performing similiar actions with the Execute SQL Task or not. Any help would be
appreciated. The exact message is as follows:
[Execute SQL Task] Error: An error occurred while assigning a value to variable "varRestoreScript": "The type of the value
(DBNull) being assigned to variable "User::varRestoreScript" differs from the current variable type (String). Variables may not change type during execution. Variable types are strict, except for variables of type Object.
User::varRestoreScript is the first return value. And even with the a dummy select the same result occurs. I have narrowed the issue down
to the T-SQL Statement structure itself.
The following works just fine within the execute sql task control as long as no resultset is configured for return:
"Declare @dynamicSQL nvarchar(max)
Select @dynamicSQL = name
From sys.databases
Where name = 'master'
Select atest_var1=@dynamicSQL, atest_var2='static'"
I have tried various iterations of the script above with no success. However, if I use the following derivative of it the task completes
successfully and variables are set as expected. This will not work for my scenario however as I need to dynamically build a string spanning multiple resultsets to build one of the variable values.
"Select atest_var1=name, atest_var2='static'
From sys.databases
Where name = 'master'
I have a sample package which can reproduce this issue using the above code. You can get to that through the post on www.sqlservercentral.com/Forums/Topic1582670-364-1.aspx
ScottArthur, the query when executed doesn't return a null value for the @dynamicSQL variable. It returns "master" as a string value. Even the following fails which implements that suggestion:
Declare @dynamicSQL as nvarchar(max)
Select @dynamicSQL = name
From master.sys.databases
Where name = 'master' -- (or any other DB name)
I believe I have found the cause of the issue. It is datatype and size related. The above script will properly set the variables in the resultset as long as you don't use nvarchar(max) or varchar(max). This makes the maximum data size for
a String variable 4000 characters whether unicode or non-unicode typed. -
Cannot assign value to a Variable of Complex Type beyond index 1
Hello:
I have a variable defined as a complex type as followed. I tried to assign a value to each of the two elements but it only allows me to assign to the 'element#1.
This statement that tries to assign a value into element#2 will not work, if I assign with '[1]' for the first element it will work:
<copy> <---- THIS WORKS
<from expression="'John'"/>
<to variable="My_Variable"
part="My_Collection"
query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item[1]/ns9:pname"/>
</copy>
<copy> <---- THIS DOES NOT WORK
<from expression="'John'"/>
<to variable="My_Variable"
part="My_Collection"
query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item[2]/ns9:pname"/>
</copy>
Is there something wrong with my definition below that allows only element#1 to be refererenced but not element#2???? Am I missing some kind of initialization that is needed to initialize both elements????
Here are my message and Complex Type definitions:
<variable name="My_Variable" messageType="ns8:args_out_msg"/>
<message name="args_out_msg">
<part name="My_Collection" element="db:My_Collection"/>
</message>
<element name="My_Collection">
<complexType>
<sequence>
<element name="Collection" type="db:Collection_Type" db:index="2" db:type="Array" minOccurs="0" nillable="true"/>
<element name="Ret" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="Collection_Type">
<sequence>
<element name="Collection_Item" type="db:Collection_Type_Struct" db:type="Struct" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
<complexType name="Collection_Type_Struct">
<sequence>
<element name="pname" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="25"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
The error msg it gives me is as followed:
[2010/09/04 00:47:59] Error in <assign> expression: <to> value is empty at line "254". The XPath expression : "" returns zero node, when applied to document shown below:less
oracle.xml.parser.v2.XMLElement@1fa7874
[2010/09/04 00:47:59] "{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.less
-<selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
-<part name="summary">
<summary>
XPath query string returns zero node.
According to BPEL4WS spec 1.1 section 14.3, The assign activity <to> part query should not return zero node.
Please check the BPEL source at line number "254" and verify the <to> part xpath query.
</summary>
</part>
</selectionFailure>
Thanks
NewbieHello:
Base on the suggestion to use 'append' instead of 'copy', I tried to define a 'singleNode' which is of type 'Collection_Type_Struct' so I can append this individual 'struct' into my array (i.e. as the 2nd. element of my array "/ns9:My_Collection/ns9:Collection/ns9:Collection_Item"), but I am getting an error in defining this variable as:
<variable name="singleNode" element="Collection_Type_Struct"/> <--- error
Can someone tell me how should I define "singleNode" so I can put a value in it and then append this 'singleNode' into the array:
<variable name="singleNode" element=" how to define this????"/>
<assign>
<copy>
<frem expression="'Element2Value'"/>
<to variable="singleNode"
part="My_Collection"
query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item/ns9:pname"/>
</copy>
</assign>
<bpelx:assign>
<bpelx:append>
<from variable="singleNode" query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item"/>
<to variable="My_Variable"
"part="My_Collection"
query="/ns9:My_Collection/ns9:Collection"/>
</bpelx:append>
</bpelx:assign>
Again here is my definition in my .xsd file:
<element name="My_Collection">
<complexType>
<sequence>
<element name="Collection" type="db:Collection_Type" db:index="2" db:type="Array" minOccurs="0" nillable="true"/>
<element name="Ret" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="Collection_Type">
<sequence>
<element name="Collection_Item" type="db:Collection_Type_Struct" db:type="Struct" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
<complexType name="Collection_Type_Struct">
<sequence>
<element name="pname" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="25"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
Thanks for any help!!!! -
Dynamically change the db and server in execute sql task
Pkg 2: Moves data from B_STG (Staging DB) to B_Det_STG (Staging DB) ---- option1
Pkg 3: Moves data from B_STG (Staging DB) to B_Det (PC DB) ---- option2
This part is duplicating in both the packages
So they want me to merge both of them into in execute sql task and dynamically change between option1 and option2 depending on a pkg level variable.
So, I create a pkg level variable called ExecutionVariable: 'ANALYSIS' or 'LOADING'
If 'ANALYSIS' it needs to do option1 else option2.
So, I ma trying to create a dynamic connection string in execute sql task.
I change the connection property in execute sql task editor dynamically my giving the expression: @[User::ExecutionVariable] == "ANALYSIS"? @[User::STAGINGDBConnectionString] : @[User::PCDBConnectionString]
which evaluates to : Data Source=AW-ETL-D1;Initial Catalog=Staging;Integrated Security=SSPI;Provider=sqloledb
But when I run the sql task, its giving me an error:
ERROR:
TITLE: Microsoft Visual Studio
Nonfatal errors occurred while saving the package:
Error at PC_DataLoad: The connection "Data Source=AW-ETL-D1;Initial Catalog=Staging;Integrated Security=SSPI;Provider=sqloledb" is not found. This error is thrown by Connections collection when the specific connection element is not found.
Error at PC_DataLoad: The connection "Data Source=AW-ETL-D1;Initial Catalog=Staging;Integrated Security=SSPI;Provider=sqloledb" is not found. This error is thrown by Connections collection when the specific connection element is not found.
Can u please help me.Hi ,
Don't try to make the "Execute Sql" task as dynamic.
Try to make OLEDB connection Manager as "Dynamic".
Steps:
1. Create OLE DB Connection pointing to any database then set expression to connection string variables like below.
Provider=SQLNCLI10.1;Integrated Security=SSPI;Initial Catalog=YourDBname;Data Source=YourServerName.
2. Make Delayed Validation property to "True".
3. Set the created dynamic OLE DB connection to your Execute SQL task.
4. Change the connection string variable accordingly before running the "Execute SQL" task.
Hope it will help you.
Regards,
Nandhu -
Multiple Select statements in EXECUTE SQL TASK in SSIS
Can we write multiple select statements in execute sql task(SSIS).
If possible how to assign them to variables in result statementHi ,
You can use below steps to set result set to variable.
1.In the Execute SQL Task Editor dialog box, on the General page, select the Single row, Full result set, or XML result set type(According to your result set).
2.Click Result Set.
3.To add a result set mapping, click Add.
4.From the Variables Name list, select a variable or create a new variable.
What is multiple selection ? May be below can be used in your scenario !
http://stackoverflow.com/questions/17698908/how-to-set-multiple-ssis-variables-in-sql-task
What you want to achieve ?
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
How can we give values to the variable
Oracle Forms6i
Hai All
I am generating an daily attendance regarding shift basis.In that i have written an ifelse condition it work successfull and but it fetches only 350 row out of 800.
I have declared a variable and i need to know how to assign values to the variable Pls tell the steps to do.I have done correctly but there is an logic error in my coding.Let give me some steps to solve the problem
My coding is
declare
t_in varchar2(25);
t_out varchar2(25);
cursor cur_test is
select * from dail_att where intime=t_in and outtime =t_out;
--into t_in,t_out from dail_att;
begin
loop
go_block('TEST_SRI');
FIRST_RECORD;
if :bartime between 0145 and 0630 then
update dail_att set outtime = :bartime where barcode= :barcode
and ATTEND_DATE = :bardate-1 and intime is null and outtime is not null;
elsif :bartime between 0630 and 0900 or :bartime between 1130 and 1230 or
:bartime between 1700 and 1800 and t_in is null then
insert into dail_att(barcode,intime,attend_date)
values(:barcode,:bartime,:bardate);
elsif :bartime > 1645 and t_in is not null and t_out is null then
update dail_att set outtime = :bartime where barcode= :barcode
and ATTEND_DATE = :BARDATE and intime is not null and outtime is null;
end if;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE' OR :BARCODE IS NULL;
NEXT_RECORD;
END LOOP;
forms_ddl('commit');
exception
when others then
forms_ddl('rollback');
message(sqlerrm||dbms_error_Text);
message(sqlerrm||dbms_error_Text);
end;
Regards
Srikkanth.MHai man
I have generated a daily attendance roll in oracle forms and it executed correctly but while fetching it fetch some of the records. So i have declared a variable in a block and in my coding.
For those variable i need to pass values from select statement or using cursor.According to that i can use in my ifelse statement.
If It is clear Or else see the coding
declare
bar_code varchar2(25);
in_time varchar2(25);-------------------------- these are the variable i going to use in select statement to pass values
out_time varchar2(25); so that i can use in if else statement.
begin
loop
go_block('TEST_SRI');
FIRST_RECORD;
select BARCODE,INTIME,OUTTIME into bar_code,in_time,out_time from dail_att where BARCODE= :Barcode
and ATTEND_DATE = :bardate;
if :bartime between 0100 and 0630 then
update dail_att set outtime = :bartime where barcode= :barcode
and ATTEND_DATE = :bardate-1 and in_time is null and out_time is not null;
elsif :bartime between 0630 and 0900 or :bartime between 1130 and 1230 or
:bartime between 1700 and 1800 and in_time is null then
insert into dail_att(barcode,intime,attend_date)
values(:barcode,:bartime,:bardate);
elsif :bartime > 1645 then
update dail_att set outtime = :bartime where barcode= :barcode
and ATTEND_DATE = :BARDATE and in_time is not null and out_time is null;
end if;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE' OR :BARCODE IS NULL;
NEXT_RECORD;
message(:barcode);
END LOOP; -
Hi,
How do I return two values from a
stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
Something like ?
CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
@intPeriod INT,
@strPeriod_Length NVARCHAR(1),
@dtStart NVARCHAR(8) OUTPUT,
@dtEnd NVARCHAR(8) OUTPUT
AS
then within the SSIS component; -
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
Add a script task to check ssis variables values using,
Msgbox(Dts.Variables("User::strExtractStartDate").Value)
Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
Regards, RSingh -
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
shamenTo 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 -
when debugging SSIS, the "Execute SQL Task" runs a stored procedure and returns the expected value. When running the package a second time, the task returns an unexpected value. When running in VS2012 SQL editor, everything operates as expected.
Please help me debug how to get the stored proc to return the same value every time the SSIS Package is run. thanks!
Here is the sequence of events and what happens....
Look for a Positor that matches the Application, Host, and User
No matching PositorId is found, Creates new Positor row, returns that new PositorId
Use PositorId to upload some data (Every thing works)
re-run/debug the ssis pacakge
Look for a Positor that matches the Application, Host, and User
<No clue what is happening>
Returns -1 (SHOULD BE the same PositorId value returned in #2)
"Execute SQL Task" Setup: No edits to Result Set nor Expressions
"Execute SQL Task" Setup: GENERAL
"Execute SQL Task" Setup: PARAMETER MAPPING
SP called by "Execute SQL Task"
CREATE PROCEDURE [posit].[Return_PositorId]
AS
BEGIN
DECLARE @PositorId INT = [posit].[Get_PositorId]();
IF (@PositorId IS NULL)
BEGIN
DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
END;
RETURN @PositorId;
END;
Supporting SQL Objects:
CREATE FUNCTION [posit].[Get_PositorId]
RETURNS INT
AS
BEGIN
DECLARE @PositorId INT = NULL;
SELECT TOP 1
@PositorId = [p].[PO_PositorId]
FROM [posit].[PO_Positor] [p]
WHERE [p].[PO_PositorApp] = APP_NAME()
AND [p].[PO_PositorHost] = HOST_NAME()
AND [p].[PO_PositorUID] = SUSER_ID();
RETURN @PositorId;
END;
GO
CREATE PROCEDURE [posit].[Insert_Positor]
@PositorNote NVARCHAR(348) = NULL
AS
BEGIN
DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
DECLARE @Id TABLE
[Id] INT NOT NULL
INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
OUTPUT [INSERTED].[PO_PositorId]
INTO @Id([Id])
VALUES(@PositorNote);
RETURN (SELECT TOP 1 [Id] FROM @Id);
END;
GO
CREATE TABLE [posit].[PO_Positor]
[PO_PositorId] INT NOT NULL IDENTITY(0, 1),
[PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
[PO_PositorName] NVARCHAR(256) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
[PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
[PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
[PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
[PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
[PO_tsInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_tsInserted] DEFAULT(SYSDATETIMEOFFSET()),
[PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
CONSTRAINT [UK__Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC),
CONSTRAINT [PK__Positor] PRIMARY KEY ([PO_PositorId] ASC)
GO
ssdThe error is in item 7: Returns -1 (SHOULD BE the same PositorId value returned in #2); but no error message is returned or thrown from SSIS.
The error message indicated referential integrity is not upheld when inserting records. This error message occurs AFTER the Execute SQL Task successfully completes; the E.SQL Task returns -1. The executed SQL code will not allow values less than 0
([PO_PositorId] INT NOT NULL IDENTITY(0, 1),)
[Platts Valid [41]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E2F.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E2F Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E2F Description:
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK__PricingPlatts_Posit_PositorId". The conflict occurred in database "Pricing", table "posit.PO_Positor", column 'PO_PositorId'.".
The aforementioned FOREIGN KEY constraint is due to the value being returned by the Execute SQL Task.; therefore, the error lies in the value returned by the Execute SQL Task. -
Environment: SQL Server 2008 R2
Code:
CREATE TABLE dbo.PkgAudit
PkgAuditID INT IDENTITY(1, 1),
PackageName VARCHAR(100),
LoadTime DATETIME ,
NumberofRecords VARCHAR(50),
Status1 VARCHAR(50),
Status2 VARCHAR(50),
The following code is inserted in the SQL Task Execute Editor
INSERT INTO dbo.PkgAudit(PackageName
,LoadTime
,NumberofRecords
,Status1
,Status2
) VALUES(?,?,?,?,?)
Screen Shot (Parameter Mapping):
Problem: an error Message occurred when I hit Parse Query Button in the Execute SQL Task Editor, "Execute SQL: Task Editor: The query failed to parse. Syntax error, permission violation, or other nonspecific error". How I could Solve this
problemDifferent connection providers require different Parameter syntax. E.g. ADO @ParameterName notatoin, not just an offset of 0,1 etc.
Arthur My Blog -
What is the difference between Execute SQL Task and OLE DB Command
Besides the obvious, Execute SQL Task being used in Control Flow, and
OLE DB Command being used in Data Flow what is the difference between the two? Is one supposed to use
Execute SQL Task to produce a result set that then gets handed over to
Data Flow and OLE DB Command ? Everything that I have seen on
OLE DB Command is pretty much execution of a Stored Procedure with ? parameters. It seems as though I got to a point where I had to perform my data edits pretty much entirely in a Stored Procedure executed by
OLE DB Command rather than trying to use the SSIS GUI for everything. I didn't really see in any of my Google searches out there that simply used
OLE DB Command as a straight parameterized SQL against tables for editing and cleansing purposes and handling returns back from SQL Server for COUNT(*), etc..
I know I have posted multiple forums out there regarding this issue but I cannot seem to get a straight answer and some solid direction. So for now, my
Execute SQL Task gives me my editable result set and then control is handed off to
Data Flow and ultimately to my Stored Procedure executed by an
OLE DB Command which pretty much does the chunking for me and performs my data edits and handles my record anomalies through SQL Server Table data stores accordingly or sets flags accordingly if the data passes.
I welcome your thoughts and Thanks for your review and Thanks in advance for any replies and direction that anyone might provide.
Hi ITBobbyP,
OLE DB Command will always process data row by row, whereas Execute SQL task if you call a Stored Procedure it can process data in bulk. As you said, the biggest difference is that Execute SQL Task being used in Control Flow, and OLE DB Command being
used in Data Flow. They are used in different places.
Using Execute SQL Task, we can save the rowset returned from a query into a variable. The Execute SQL task can be used in combination with the Foreach Loop and For Loop containers to run multiple SQL statements. These containers implement repeating control
flows in a package and they can run the Execute SQL task repeatedly. For example, using the Foreach Loop container, a package can enumerate files in a folder and run an Execute SQL task repeatedly to execute the SQL statement stored in each file. I think this
is a big advantage for Execute SQL Task.
As to OLE DB Command, we can easily run an SQL statement for each row transformation in a data flow, then directly insert the outputs to a destination.
To sum up, there are many difference between those two components. We should make better choice based on our actual requirement.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Error while executing the Job:Cannot assign NULL to host variable 1
Hello!
I have the following issue:
Error while executing the Job:Cannot assign NULL to host variable 1. setNull() can only be used if the corresponding column is nullable. The statement is "INSERT INTO "VIRSA_... (see log for details)
Note 1362138 - Rule generation - null pointer exception virsa_cc_rtmap doesn't me. After uploading files of ZCC_DOWNLOAD_SAPOBJ and ZCC_DOWNLOAD_DESC I got the same problem during job running...
How can I find out where is the problem?Hi
That looks like your fields are disabled but they could still be causing the problem edited ( nah - talking rubbish as you've put dummy " " in there) edited - the 'null' error caused many background jobs to fail but, once we had the evidence to show the space (somebody had pressed enter instead of delete/backspace to clear the entry) it stopped the problem - just a bit of learning on the job which we all go through for the GRC chaps in KL.
A " " would be valid but a (I know you can't see it but it's there wouldn't be )
edited.When you did an edit/replace did it say it had replaced anything please?edited
The word doc option does sound good!
Cheers
David
Edited by: David Berry on Nov 4, 2010 7:33 PM -
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.
ShanmugaRajTo avoid this error, the RetainSameConnection property should set to 'True' for the Connection Manager - Application_DB.
Narsimha -
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 meWhat 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] -
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
Maybe you are looking for
-
How do I move a project between machines?
Hi, I'm an SQL Server novice. After developing some websites (VS 2005 VWD), my machine started to crumble. (e.g, SQL Server won't uninstall and lots of other software problems) So I bought a new machine and set up a clean installation of SQL Server
-
Dear Experts, I have a source structure as follows: <Header> <Header1>first </Header1> <Header2>second</Header2> <Header3>third</Header3> <LineItem> <Item1>one</Item1>
-
Site showing nothing but index?
Hi, When I was in college I used Dreamweaver in CS3 to build my website. I let my site sort of lie fallow for years and now I'm having to update it, but I barely remember how to use Dreamweaver at all. For some reason when I tried to update my site,
-
Converting ANSI 850 messages in Seeburger from XML to EDI
Hi, I really wish for your help with regard to the following error: [Error:ID=2012;LEVEL=3] InhouseDocReader doSyntaxCheck() Offset[2]: Could only identify segment S_N1 as dirty! (Counter exceeds)DESCRIPTION: InhouseDocReader: Syntax che
-
Problem getting Count Of ChildNodes (JAXP)
I am trying to process an XML Document like <Report siteID="1234567"> <Transaction transactionDetail="VFVF56760482" referenceNumber="32293642" date="09-01-2003 09:30 AM"> <Item modelNo="" serialNo="" quantity="1" price="250.00" total="250.00" descrip