Solved

SQL Server 2008 error trying to return number of table in a DB

Posted on 2013-11-14
3
240 Views
Last Modified: 2013-11-14
See attachment of error and select statement when trying to return a count of number of tables in a database.
SQLErr.JPG
0
Comment
Question by:bjbrown
3 Comments
 
LVL 2

Expert Comment

by:burdit
ID: 39649057
Why are you debugging it? Just hit F5 (execute).
0
 
LVL 10

Accepted Solution

by:
PadawanDBA earned 500 total points
ID: 39649063
If you're looking for the number of tables in a database, why don't you just use:

use <database_to_count>
go;

select
    count( 1 ) as tableCount
from
    sys.tables;

Open in new window

0
 

Author Closing Comment

by:bjbrown
ID: 39649087
Thanks for the quick response and accurate solution.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

828 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