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

Wired COUNT (*) behaviour, it returns null in place of 0 Expand / Collapse
Author
Message
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, June 17, 2014 7:45 AM
Points: 27, Visits: 120
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