Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Really Strange Expand / Collapse
Author
Message
Posted Monday, February 18, 2013 9:16 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, November 7, 2014 2:00 PM
Points: 979, Visits: 3,364
Hello Everyone
I hope that your day has been better than mine.

I have been working most of the day with a SSIS Package that is giving me a really strange effect.

I will keep this really simple.

I have two tables, the SSIS package is filling table1 from a flat text file source. Table2 is being filled with the data from Table1 using an Execute SQL Step, in which I call a stored procedure. Both tables have the same columns.

When I execute the package, the data from the text file is loaded into Table1, and then the next step is calling the sproc to load the data into Table2. Which it does, but there are a large number of different rows in table1 than are in Table2. Different every time, but approx 16000 rows are inserted into Table1, which is the exact number in the text file. But there are approx 14,000 up too 15,500 rows that are inserted into Table2. The query is a simple. This is a straight data insert from one table to another.
INSERT INTO dbo.Table2
SELECT
Column1
, Column2
, Column3
, Column4
, Column5

FROM dbo.Table1

I have no idea what is causing some rows to not be inserted. Oh, I created the tables using the same script, changing only the name for each table.

I have tried this same package on multiple servers, picking up the same text file(s). There are different files per day. I have take some that are waiting to be processed, but were created up too a couple weeks ago. I have created multiple packages, one package exactly the one that is running, and others with only a couple steps in them. Just enough to pump the data from one table to another.

I have never seen anything like this before. I am hoping that someone has some advice, or a suggestion as to what to look for that may be causing this rather odd insert.

Thanks You in advance for all your assistance, suggestions and advice.

Andrew SQLDBA
Post #1421418
Posted Monday, February 18, 2013 10:26 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, April 24, 2014 9:12 AM
Points: 285, Visits: 504
Sounds like the data in the file isn't completely loaded into table1 before you start the insert into table2, maybe getting dirty reads... what isolation level? I'm going to assume that table1 is a staging table and table2 is the prod table? If not why not just use multicast task to load both table at the same time from the source file...
maybe explicitly start a transaction around the first task of loading table1 or put a pause between loading table1 to inserting table2...


---------------------------------------------------------------
Mike Hahn - Future MCM 2025
Right way to ask for help!!
http://www.sqlservercentral.com/articles/Best+Practices/61537/
I post so I can see my avatar
I want a personal webpage
I want to win the lotto
I want a gf like Tiffa
Post #1421429
Posted Tuesday, February 19, 2013 5:14 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, November 7, 2014 2:00 PM
Points: 979, Visits: 3,364
I think that I forgot to mention this.

I can write a query of the same thing that is in the sproc, and it works fine, inserts all rows.

This is driving me insane at this point.

Anyone else have any suggestions?

Thanks
Andrew SQLDBA
Post #1421574
Posted Tuesday, February 19, 2013 5:23 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 8:28 AM
Points: 955, Visits: 2,638
Can you post the code in the SP, as that might help us see what's going on.

I take it you've don't a count on the source table and that matches the number of rows in the text file.


_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1421582
Posted Wednesday, February 20, 2013 10:50 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, October 28, 2014 12:50 PM
Points: 1,061, Visits: 2,580
AndrewSQLDBA (2/18/2013)
Hello Everyone
I hope that your day has been better than mine.

I have been working most of the day with a SSIS Package that is giving me a really strange effect.

I will keep this really simple.

I have two tables, the SSIS package is filling table1 from a flat text file source. Table2 is being filled with the data from Table1 using an Execute SQL Step, in which I call a stored procedure. Both tables have the same columns.

When I execute the package, the data from the text file is loaded into Table1, and then the next step is calling the sproc to load the data into Table2. Which it does, but there are a large number of different rows in table1 than are in Table2. Different every time, but approx 16000 rows are inserted into Table1, which is the exact number in the text file. But there are approx 14,000 up too 15,500 rows that are inserted into Table2. The query is a simple. This is a straight data insert from one table to another.

INSERT INTO dbo.Table2
SELECT
Column1
, Column2
, Column3
, Column4
, Column5

FROM dbo.Table1

I have no idea what is causing some rows to not be inserted. Oh, I created the tables using the same script, changing only the name for each table.

I have tried this same package on multiple servers, picking up the same text file(s). There are different files per day. I have take some that are waiting to be processed, but were created up too a couple weeks ago. I have created multiple packages, one package exactly the one that is running, and others with only a couple steps in them. Just enough to pump the data from one table to another.

I have never seen anything like this before. I am hoping that someone has some advice, or a suggestion as to what to look for that may be causing this rather odd insert.

Thanks You in advance for all your assistance, suggestions and advice.

Andrew SQLDBA


Have you adjusted the "Rows Per Batch" or "Maximum Insert Commit Size" properties of your Destination connection? If so, SSIS is sending the data to SQL Server in chunks that SQL Server handles as separate transactions. If your package sends 10 batches of rows to SQL Server then executes the stored procedure, SQL Server may have only completed and committed 8 or 9 of those batch transactions when the stored procedure begins to read data from that table. Isolation ensures that the stored procedure will only see rows that are committed when it begins its SELECT (unless you've tinkered with isolation levels or used hints like NOLOCK). That may explain why you get varying numbers of rows in the second table each time you run the package.


Jason Wolfkill
Blog: SQLSouth
Twitter: @SQLSouth
Post #1422212
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse