SSIS list rows that do not update - sql-server

I am using an OLE DB Command to update records in a table. I want to seperate rows that update successfully from rows that do not update (different than error). Some rows will not update because the key I am updating does not exist. This is different than an error, because the command ran so I can not use the red error line. The only idea I have would be the equivalent to when I execute the update in SQL Server and it says "(0 row(s) affected)" and I would be able to do a comparison.
Since this does not count as an error in SSIS, I can't use the red error line. Does anyone know how to catch records that do not update?

catch it in a table
Select *
INTO Some_table
FROM Table_you_are_updating_From as a
WHEre NOT EXISTS(Select *
FROM Table_you_are_updating as b WHERE a.key=b.key )

Related

Informatica only insert last data row into database table

I am a newbie in informatica tool.
I run a workflow to insert data from database A, table A.A to database B, table B.B. Session did succeed.
And I met a problem in log file:
Database errors occurred:
Execute -- Informatica' ODBC 20101 driver27376073
Execute -- ODBC Driver Manager Function sequence error
When last step to insert data to B.B
It is only 1 row inserted per workflow running time. Example: I have 7 rows, only 1 row inserted and 6 rows rejected.
I search for 27376073 error code but I found nothing about it.
Can anyone help me solve this problem, please?
are you using aggregator transformation cheak groupby port marked or not
and if source is a FF and fixed width we need to do some settings in session task

VBA SQL Bulk insert excepton handling

I have to execute CSV records as batch by batch to SQL Server. In the macro, I am framing SQL query based on the record in the foreign key. So, I can not go for BULK Insert here.
I written code to iterate 100 rows and save in String like below:
Insert into table ('name','address','region') values ('Test','xxx-test-address',1);
Insert into table ('name','address','region') values ('Test','xxx-test-address',1);
Insert into table ('name','address','region') values ('Test','xxx-test-address',1);
Insert into table ('name','address','region') values ('Test','xxx-test-address',1);
Now, I am executing 100 SQL inserts against SQL Server. Let's say if error is thrown at 50th row then remaining 50 rows are not executed and error throwing at VBA.
My question is how do I find which row is throwing error?
If can not be achieved in this approach, please let me know the approach to achieve. Since 10000 or more records will be in CSV, I can not execute the records in iteration. This will hit database many times.
Thanks in advance!

How to check in UPDATE Trigger if record has really changed

I have a SQL Server 2012 UPDATE Trigger which occurs when data is updated within a table in the database (Microsoft Project Server Database) :)
I am using the following statement to get the updated element from the table within the Trigger
SELECT #dataId = INSERTED.Id FROM INSERTED;
But the problem is due to the behaviour of the Microsoft Project Server, that it updates ALL Tasks within a Project even if only one task was changed (each Task is one record in database).
I know that i can get the id of the item which should be updated, but i dont know how i could compare the to updated row with the data which is still in the database within the UPDATE Trigger?
To get what rows actually changed, then use this inside the trigger
SELECT
*
FROM
INSERTED I
JOIN
DELETED D ON I.KeyCol = D.KeyCol
WHERE
NOT EXISTS (
SELECT I.Col1, I.Col2, I.Col3, I.Col4 ...
INTERSECT
SELECT D.Col1, D.Col2, D.Col3, D.Col4 ...
)
The NOT EXISTS..INTERSECT deals with NULLs etc for you already

Sql server drop table not working

I have a table with almost 45 million rows. I was updating a field of it with the query:
update tableName set columnX = Right(columnX, 10)
I didn't do tran or commit but directly ran the query. During the execution of query, after an hour unfortunately power failure occurred and now when i try to run select query it takes too much time and returns nothing. Even drop table doesn't work. I don't know what is the problem.
I don't know what is the problem.
SQL server is rolling back your update statement..you can monitor the status of rollback ,using many ways
1.
kill sessionid with status only
2.By using DMV
select
der.session_id,
der.command,
der.status,
der.percent_complete
from sys.dm_exec_requests as der
where command IN ('killed/rollback',’rollback’)
Dont try to restart SQLServer,as this may prolong the status..

ADODB affected rows return trigger's affected rows

I have a VBA that runs a command text to update a table. The table has a trigger on UPDATE.
When I do:
Set rs = cmd1.Execute(affectedCount)
the affectedCount returns affected rows from trigger (I think).
How do I make it return the original update statement's affected row count?
Assuming you're using SQL Server, I had a similar problem a while ago. I'm not sure if it's related but ADODB would get "confused" by the "# records affected" messages that were generated by SQL Server.
We solved this by adding
SET NOCOUNT ON
To the top of affected triggers / procedures to suppress the message. You can then try running your statement from SQL Management Studio to see exactly which "# records affected" messages are being generated.
Don't know if this will help but maybe worth a try.

Resources