Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser..."Count" Stored Procedure Always Returns 0"Count" Stored Procedure Always Returns 0
Previous
 
Next
New Post
7/15/2011 3:50 PM
 
Ruben Lopez wrote:
I've tried your scripts and the first stored procedure works for me. So you could try what Cathal says or look at your database configuration.

That's just it...  It normally works.  This is a very trivial query.  :(

If it's a database configuration issue, this should happen to all similar queries, right?  The same exact query in another SProc works fine - the only difference being that it's pointing to another table.  It will returns a count of the table, based on the WHERE clause.

Cathal Connolly wrote:
you can use select count(*) as you're constraining the list via your where clause - take care using non count(*) functions as it's not always obvious e.g. listing a column gives a count of the unique values (which may not always be a count of the rows if some rows share the same values - which isn't the case with an identity column which is why you'll sometimes see that usage) - see http://msdn.microsoft.com/en-us/library/ms175997.aspx for the correct ALL and DISTINCT usages also.

I use this method of count mostly for performance.  There's less of a hit on the DB when using the PK field, because there aren't any additional look-ups required on the table.  This may not still be true, as I first learned this during the SQL Server 2000 era.  :)

Cathal Connolly wrote:
try using SELECT COUNT(i.[ImageId] is not null)

I've never tried this before, but it wouldn't execute.  SQL Server was complaining to me, saying it wasn't valid...  "Incorrect syntax near the keyword 'IS'."


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
10/7/2011 2:38 AM
 
Ugh...  Don't know why I cannot get this done consistently. Sometimes it works, and sometimes it doesn't.  http://screencast.com/t/kn5lfTC0CZJh

Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser..."Count" Stored Procedure Always Returns 0"Count" Stored Procedure Always Returns 0


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out