Comparing two counts from two tables

266 views
Skip to first unread message

daniel...@skipton.co.uk

unread,
Dec 3, 2013, 5:27:25 AM12/3/13
to db...@googlegroups.com
Can anyone help me on this, I'm trying to run a count on a table in one database and check that its the same in another..something along the lines of:
 
!path lib/*.jar
!|dbfit.SqlServerTest|
 
!|Connect|dbone|dbfit_test|dbfit_test|U_ODS|
 
!|Store Query|select count(*) from db.CUST|output2|
 
!|Connect|dbtwo|dbfit_test|dbfit_test|CORE|
!|Store Query|select count(*) from dbo.CUST AS sourceNo|output1|
 
|compare stored queries|output1|output2|
|count|
...I can run the two queries fine but I'm not sure how to compare them and test that they are the same? Any help?
 
Thanks,
Dan.

Jake Benilov

unread,
Dec 6, 2013, 9:15:23 AM12/6/13
to db...@googlegroups.com
Hi Daniel,

That looks right, and should actually work. I've just run (a slightly simplified version of) your test under MySQL and it works, meaning that from a database-agnostic approach it's OK, however I don't have a SQL Server instance to hand to be able to reproduce it. The only thing that comes to mind is to try to give the count(*) columns a name (eg count(*) as count)...

What error messages are you seeing when you run your test?

Jake

daniel...@skipton.co.uk

unread,
Dec 6, 2013, 10:46:52 AM12/6/13
to db...@googlegroups.com
Managed to get it to do what I wanted with the below...not sure its 'pure' but it works. The compare functions seems to expect a table?
 
!path lib/*.jar
!contents -R -g -p -f -h
!|dbfit.SqlServerTest|
|Set parameter|expectedValue1|0|
!|ConnectUsingFile|FitNesseRoot\files\Connections\U_ODS.txt|
|Query|SELECT SUM(Total) AS TotalRecords_ODS FROM (SELECT COUNT(*) AS Total FROM TABLEA UNION SELECT COUNT(*) AS Total FROM TABLEB) records|
|TotalRecords_ODS?|
|>>expectedValue1|

!|ConnectUsingFile|FitNesseRoot\files\Connections\U_DW.txt|
|Query| select count(*) - @expectedValue1 as expectedDifference from TABLEC|
|expectedDifference|
|0|

Jake Benilov

unread,
Dec 6, 2013, 10:49:43 AM12/6/13
to db...@googlegroups.com
Good to hear that you got it to work, but still curious as to the errors you were seeing with your original test?


--
You received this message because you are subscribed to the Google Groups "dbfit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbfit+un...@googlegroups.com.
To post to this group, send email to db...@googlegroups.com.
Visit this group at http://groups.google.com/group/dbfit.
For more options, visit https://groups.google.com/groups/opt_out.

pooja jindal

unread,
Feb 19, 2020, 7:43:21 AM2/19/20
to dbfit
Is there any other way to compare row count with DB fit .I am comparing 02 tables count which are under different Databases.

Both the above queries are not working at my end.Please suggest
To unsubscribe from this group and stop receiving emails from it, send an email to db...@googlegroups.com.

Mark Matten

unread,
Feb 25, 2020, 2:49:56 AM2/25/20
to dbfit
If you can post your test page contents here then we can try to help.
Reply all
Reply to author
Forward
0 new messages