Solved

Syntax for SELECT COUNT(...) FROM

Posted on 2010-11-21
3
464 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
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:
ewangoya 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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, …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now