• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

NEWBIE: How to get a count of rows?

Dear Experts,

Please forgive such a dumb question, but...

I'm trying to simply get a count of rows in a particular MS SQL Server table.  My syntax goes:

  SELECT COUNT(*) AS rowcount FROM MYTABLE

What's wrong?  Is it the asterisk?

Thanks,
BrianMc1958
0
BrianMc1958
Asked:
BrianMc1958
  • 2
1 Solution
 
rafranciscoCommented:
Change rowcount to Row_Count and it should work.
0
 
rafranciscoCommented:
You may wonder why.  RowCount is a reserved word in SQL Server.
0
 
BrianMc1958Author Commented:
Yes!  I certainly was wondering!  Thanks!  That saves me about five hours of syntax hell.

Yours,
BrianMc1958
0
 
obahatCommented:
Use
SELECT COUNT(*) AS [rowcount] FROM MYTABLE
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now