?
Solved

Syntax for SELECT COUNT(...) FROM

Posted on 2010-11-21
3
Medium Priority
?
499 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 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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, …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

762 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