Solved

Syntax for SELECT COUNT(...) FROM

Posted on 2010-11-21
3
452 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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