0

2 stored procedures are developed by .net developers. which are giving same record counts when you pass the same parameter?

now due to some changes , we are getting mismatch record count i.e

if first stored procedure is giving 2 records for a paramemter , the second SP is giving only 1 record.

to find this i followed the approach like i verified

  1. i counted total records of a table after joining
  2. total tables used in joining 3.distinct / group by is used in 2 tables or not?

finally i am not able to find the issue.

how do i fix it?

could any body share some ideas.

thanks in advance?

Prasad
  • 65
  • 4
  • 13
  • You will need to add some code and tables. – gbn May 02 '13 at 13:25
  • I'm not sure what answer you expect here: you're saying that two different pieces of code do something different, which isn't surprising. Have you actually looked at their code? What are the "some changes"? Have you [diffed](http://en.wikipedia.org/wiki/Diff) the source code of the two procedures to find the difference? And if both procedures are effectively the same, why not just throw one away and continue using the other (correct) one? – Pondlife May 02 '13 at 19:51

1 Answers1

0

Assuming the same JOINs and filters, then the problem is NULLs.

That is, either

  • A WHERE clause has a direct NULL comparison which will fail
  • A COUNT is on a nullable column. See Count(*) vs Count(1) for more

Either way, why do you have the same very similar stored procedures written by 2 different developers, that appear to have differences?

Community
  • 1
  • 1
gbn
  • 422,506
  • 82
  • 585
  • 676