I have to execute some Update statements from SSIS to Oracle which I cannot put into a stored Proc. This statement runs fine in Oracle, but I get error when executing from SSIS. I am using an Execute SQL Task with properties SQL Source Type = Direct Input, BypassPrepare = True. On executing the task, it just hangs for 20 minutes or so. Then I clicked on stop debugging.
UPDATE Table1 R
SET R.Column1 =
(SELECT SUM (Column2)
FROM Table2 M
WHERE
M.Column3 IS NULL AND M.Column4 = R.Column4)
WHERE EXISTS ( SELECT Column4 AS Column4
FROM Table2 M
WHERE
M.Column3 IS NULL AND M.Column4 = R.Column4
GROUP BY Column4) `
When this happened to me, it was because I had left a transaction open. I had been using SQL Developer to reset column values in the target table during testing. (SQL Developer doesn't use implicit transactions by default.)
Here's the detail:
SSIS PL/SQL task hangs with message “Multiple-step OLE DB operation generated errors.”
Related
I am developing a SSIS package in bids and getting an inconsistent error SSIS "Insert bulk failed due to a schema change of the target table nOT CONSISTENT for one of my dataflows. It is successful sometimes but also fails sometimes giving the above mentioned error.
I am not sure what is happening.
Following is storedproc which is called from oledb source
CREATE PROCEDURE [dbo].[getPartiesIpoData_SSIS]
AS
BEGIN
SELECT
c.companyId 'companyId',
tpf.transactionPrimaryFeatureName 'transactionPrimaryFeatureName',
os.statusdatetime 'statusdatetime',
st.statusName 'statusName'
FROM ciqCompany c
inner JOIN ciqTransOffering t
ON t.companyId = c.companyId
JOIN ciqTransOfferToPrimaryFeat ttp
ON ttp.transactionId = t.transactionId
JOIN ciqTransPrimaryFeatureType tpf
ON tpf.transactionPrimaryFeatureId = ttp.transactionPrimaryFeatureId
JOIN ciqtransofferingstatustodate os
ON os.transactionId = t.transactionId
JOIN ciqtransactionstatusType st
ON st.statusId = os.statusId AND st.statusId = 2
WHERE tpf.transactionPrimaryFeatureId = 5
CREATE NONCLUSTERED INDEX IX_PartiesIpoData_companyId on CoreReferenceStaging.dbo.PartiesIpoData(companyId) with (DROP_EXISTING =on)
END
The destination schema is as follows
The oledb destination set in SSIS is as follows
Below is some of the action plan you can try, this helped in my case though.
1) Drop the Constraints before the its run and recreate them after the run
2) Disable the Auto update stats (To isolate the issue)
3) Check if any parallel index rebuilds happening.
4) check with without using "fast load" option
If still the issue persists after implementing the above change, collect the Profiler trace to capture the activity when it is failing to further investigation.
Check This
also check setting for SQL Server Destination Adapter
If still the issue persists after implementing the above change, collect the Profiler trace to capture the activity when bcp is failing to further investigation.
I need to execute a SSRS reports from SSIS on periodic schedule.
Saw a solution here :
https://www.mssqltips.com/sqlservertip/3475/execute-a-sql-server-reporting-services-report-from-integration-services-package/
But is there any other option in SSIS without using Script Task ? I don't quite understand the script and concern there could be some support issue for me.
Database : SQL Server 2008R2 Standard Edition
Any ideas ? Thanks very much ...
SSIS controlling the running of an SSRS in SQL Agent.
This assumes that the SSIS job will have updated a control record or written some other identifiable record to a database.
1. Create a subscription for the report.
2. Run this SQL to get the GUID of the report
SELECT c.Name AS ReportName
, rs.ScheduleID AS JOB_NAME
, s.[Description]
, s.LastStatus
, s.LastRunTime
FROM
ReportServer..[Catalog] c
JOIN ReportServer..Subscriptions s ON c.ItemID = s.Report_OID
JOIN ReportServer..ReportSchedule rs ON c.ItemID = rs.ReportID
AND rs.SubscriptionID = s.SubscriptionID<br>
3. Create a SQL Agent job.
a. Step 1. A SQL statement to look for data in a table containing a flagged record where the Advanced setting is "on failure end job reporting success"
IF NOT exists ( select top 1 * from mytable where mykey = 'x'
and mycondition = 'y') RAISERROR ('No Records Found',16,1)
b. Step 2
USE msdb
EXEC sp_start_job #job_name = ‘1X2C91X5-8B86-4CDA-9G1B-112C4F6E450A'<br>
Replacing the GUID with the one returned from your GUID query.
One thing to note though ... once the report subscription has been executed then as far as SQL Agent is concerned then that step is complete, even though the report has not necessarily finished running. I once had a clean up job after the Exec step which effectively deleted some of my data before the report reached it!
You can create a subscription for the report that is never scheduled to run.
If you have the Subscription ID, you can fire the report subscription using a simple SQL Task in SSIS.
You can get the Subscription ID from the Report Server database. It is in the Subscriptions table.
Use this query to help locate the subscription:
SELECT Catalog.Path
,Catalog.Name
,SubscriptionID
,Subscriptions.Description
FROM Catalog
INNER JOIN Subscriptions
ON Catalog.ItemID = Subscriptions.Report_OID
In SSIS, you can use this statement, inside of a SQL Task, to fire the subscription:
EXEC reportserver.dbo.AddEvent #EventType='TimedSubscription',#EventData= [Your Subscription ID]
Hope this helps.
I have created a table called DimInternationalFunction.
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[DimInternationalFunction]') AND type in (N'U'))
DROP TABLE [DimInternationalFunction]
Go
Create Table DimInternationalFunction
(IntFunctionKey int NOT NULL identity primary key,
SubSubFunctionString char(10),
FunctionCode char(3),
SubFunctionCode char(6),
SubSubFunctionCode char(10),
SubSubFunctionName nvarchar(60),
SubFunctionName nvarchar(60),
FunctionName nvarchar(60))
I have initially inserted records in this table in SSMS.
After inserting the initial records manually in SSMS, now my manager wants me to insert "new records only" using SSIS.
I have tried using this in SSMS and it worked. Either it gives me 0 records inserted or sometimes it gives me 5 records inserted as a result. My manager wants me to do this in SSIS.
I tried using this script inside the OLE DB Source under Data Access Mode: SQL Command and SQL Command text:
insert into DWResourceTask.dbo.DimInternationalFunction
select f.SubSubFunctionString,
f.FunctionCode,
f.SubFunctionCode,
f.SubSubFunctionCode,
f.SubSubFunctionName,
f.SubFunctionName,
f.FunctionName
from ODS_Function F
where FunctionViewCode = 'INT'
and not exists (select * from DWResourceTask.dbo.DimInternationalFunction I
where (f.SubSubFunctionString=i.SubSubFunctionString
and f.FunctionCode=i.FunctionCode
and f.SubFunctionCode=i.SubFunctionCode
and f.SubSubFunctionCode=i.SubSubFunctionCode
and f.SubSubFunctionName=i.SubSubFunctionName
and f.SubFunctionName=i.SubFunctionName
and f.FunctionName=i.FunctionName)
)
The error message that I got after clicking preview is
The component reported the following warnings:
Error at Int Function [International Function Table [33]]: No column information was returned by the SQL command.
Choose OK if you want to continue with the operation.
Choose Cancel if you want to stop the operation.
Is there another component in SSIS that can do this? or can I just use either exec sql task component or ole db source?
I am thinking of using exec sql task connected to a data flow task, inside the data flow task I will put ole db source containing a staging table and do a delete on that or is there any other way to do it. Please help. Thanks in advance.
You could do it with an Execute SQL task.
If you want to do it "the pure SSIS way", you could use a lookup component. Set the "rows with no matching" handler to "Redirect to no match output", and configure the target table as connection. Then use the "No Match Output" only, ignoring the "Match Output". And send the records from the "No Match Output" to the target.
In spite of its name, the "Lookup" component can be used to filter data in many cases.
But I would assume the Execute SQL task would be more efficient for large data sets, keeping all data within the database engine.
I use Oracle Database Link to query data from SQL Server. The query is like:
select *
from tableA#DL_SqlServer a
join tableB#DL_SqlServer b
on a.ID = b.ID
tableA and tableB is large and the result is relatively small. This query executes quickly in SQL Server since indexes are built both on the two tables. But it is very slow on Oracle Database Link to SQL Server. I guess the join operation is performed on Oracle side not on SQL Server side, thus the indexes are not used. Since I just need the joined result, I prefer to perform the query entirely on SQL Server and get the small result only. I konw that using SQL Server's linked server and OPENQUERY function can achieve this goal. I wonder how to do this on Oracle Database Link. Thanks! Btw, I have no privilege to create views on SQL Sevrer.
You most likely need to use the DBMS_HS_PASSTHROUGH package. Something like
DECLARE
l_cursor PLS_INTEGER;
BEGIN
l_cursor := dbms_hs_passthrough.open_cursor#dblink_to_sql_server;
dbms_hs_passthrough.parse#dblink_to_sql_server( l_cursor, <<select statement>> );
while dbms_hs_passthrough.fetch_row#link_to_sql_server(l_cursor) > 0
loop
dbms_hs_passthrough.get_value#dblink_to_sqlserver( l_cursor, 1, <<local variable for first column>> );
dbms_hs_passthrough.get_value#dblink_to_sqlserver( l_cursor, 2, <<local variable for second column>> );
...
end loop;
dbms_hs_passthrough.close_cursor#dblink_to_sqlserver( l_cursor );
END;
I have a Linked Server set up on my host Server: "MyLinkedServer"
I have an SP on my server "HostServer".
I am calling a stored proc on HostServer that updates a table in DatabaseA on MyLinkedServer with values from a table in DatabaseB on MyLinkedServer.
I have other SPs that run fine in the same scenario, but they are doing inserts and deletes, however this SP fails to update the table in DatabaseA (no error returned, just no changed data), and if I change connections to actually run the SP on "MyLinkedServer" it works without a problem.
UPDATE MyLinkedServer.DataBaseA.dbo.MyTable
SET Column1 = db2.Column1
FROM MyLinkedServer.DataBaseA.dbo.MyTable db1
INNER JOIN
(
SELECT TOP 1 Column1
FROM MyLinkedServer.DataBaseB.dbo.MyTable db2
WHERE db2.Id = 2
) AS db2 ON db2.Id = 2
WHERE db1.Id = 1
I believe you'll need to reference the alias you reference in the from statement. Does changing
UPDATE MyLinkedServer.DataBaseA.dbo.MyTable
into
UPDATE db2
fix your issue?