Solved

Syntax for SELECT COUNT(...) FROM

Posted on 2010-11-21
3
496 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 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