Solved

Syntax for SELECT COUNT(...) FROM

Posted on 2010-11-21
3
488 Views
Last Modified: 2012-06-27
Hi there.  On my SQLExpress server, I have several Databases.  How do I write a query for a specific Database Table ?  I am trying to get the count of the number of records in a table.  This is what I have so far, but of course it doesn't work:

SELECT COUNT(RecordID) FROM Settings WHERE RecordID > 0

Settings is the table name, and WebBook is the name of the database.  It would seem that I should identify the database at some point.

Thank you for your help.
0
Comment
Question by:Agent909
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Expert Comment

by:kingjely
ID: 34185251
What is the error, or does it run but return 0 records?
Have you got the database selected?
Theres nothing wrong with the query.

Is it possibly,
SELECT COUNT(RecordID) FROM WebBook.Settings WHERE RecordID > 0

0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 34185294

change the current database, then run your query

USE WebBook

SELECT COUNT(RecordID) FROM Settings WHERE RecordID > 0
0
 
LVL 1

Author Closing Comment

by:Agent909
ID: 34185317
Thank  you for a quick and easy solution!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question