Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Wired COUNT (*) behaviour, it returns null in place of 0 Expand / Collapse
Posted Tuesday, June 18, 2013 6:38 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, May 17, 2016 7:23 AM
Points: 27, Visits: 194
This problem is weird. The stored procedure in QA and my local are identical. But the “count(*)” returns “null” on QA which caused exception, while it returns 0 in my local.
I couldn’t figure out why.
I have tried to change from “SELECT @temp = COUNT (*)” to “SELECT @temp = COUNT (FieldName)” in the stored procedure and that change fixed the problem. Later I changed the stored procedure back to use “SELECT @temp = COUNT (*)”, but now it returns 0 instead of NULL.
I could change all contact search stored procedures to use “SELECT @temp = COUNT (Field)” as a workaround to fix the problems in QA and local. But I don’t know why the same stored procedure behave differently in different Sql servers.
I didn’t find anything like that on Google search. Have you guys ever seen this behavior before?

Any help highly appreciable.
Post #1464623
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse