SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Row count difference between flat file source and sql table


Row count difference between flat file source and sql table

Author
Message
Lowell
Lowell
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28494 Visits: 39972
DevDB (4/11/2013)
Look for the line breaks in the export. That will cause the difference in count.


excellent point, something like this would be five rows in a text editor, but one row of data, if the row terminator was \n or some other custom terminator
'A string{cr}
with Carriage Returns{cr}
that finally ends {cr}
with a{cr}
{cr}{lf}'

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

cafescott
cafescott
SSC-Addicted
SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)SSC-Addicted (400 reputation)

Group: General Forum Members
Points: 400 Visits: 733
Line breaks meaning carriage returns. I have an SSIS package that dumps out tables from a database into flat files and I have to verify the counts in the files match the table sizes. My package creates SQL statements for each table. For each field that is of type char, varchar, text, etc., I replace the carriage returns with some other marker. (We use ^^).

The query for a single table looks like:

select field1, replace(field2, Chr(13) & char(10), '^^'), field3...from myTable

The package then opens up each sql statement and a single script task generates the output data (as opposed to using a data flow task).

Just to be thorough, once the output files are created I have another script task that opens each one, counts the lines and compares the line count to what is expected. If a line count is off for a single file the package fails and my log table has an entry indicating which file's count was off.
jdbrown239
jdbrown239
Old Hand
Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)

Group: General Forum Members
Points: 310 Visits: 409
Mystery solved: I was not getting an accurate row count using
select APPNUMBER = COUNT(*) from SCORECARDAPP_TEST _new

When querying the dmv I was able to get the exact count as the flat file.

SELECT SUM (row_count)
FROM sys.dm_db_partition_stats
WHERE object_id=OBJECT_ID('SCORECARDAPP_TEST_new')
AND (index_id=0 or index_id=1);

Thanks Everyone!

Doug
jdbrown239
jdbrown239
Old Hand
Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)Old Hand (310 reputation)

Group: General Forum Members
Points: 310 Visits: 409
Nice package. Do you have the code posted some where?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search