I want to get a resultset of every table in the database, with the
current record count of each. What is the easiest way to do this?
I can get the list of tables with:
Select s.name from sysobjects s where xtype = 'U'
each s.name is a table name, but I'm not sure how to join a record count
column to the resultset.
Thanks,
RickN 4 10135
Assuming your statistics are up to date you can use
SELECT rows
FROM sysindexes
WHERE id = OBJECT_ID('<tab le_name>') AND indid < 2
This will perform better than
SELECT COUNT(*) from <table_name>
This info is from http://www.sql-server-performance.com/
You could use a cursor to loop through the list of tables and stuff the
counts into a temp table. Perhaps someone else will have a way to do this
without a cursor.
Hope this helps,
CJ
"Rick" <ri**@abasoftwa re.com> wrote in message
news:28******** *************** ***@posting.goo gle.com... I want to get a resultset of every table in the database, with the current record count of each. What is the easiest way to do this?
I can get the list of tables with:
Select s.name from sysobjects s where xtype = 'U'
each s.name is a table name, but I'm not sure how to join a record count column to the resultset.
Thanks, RickN
So this would be the non-cursor solution:
select o.name, i.rows
from sysobjects o, sysindexes i
where i.id = OBJECT_ID(o.nam e)
and i.indid = 0
Shervin
"CJ" <ch***@hrn.or g> wrote in message news:bk******** **@reader2.nmix .net... Assuming your statistics are up to date you can use
SELECT rows FROM sysindexes WHERE id = OBJECT_ID('<tab le_name>') AND indid < 2
This will perform better than
SELECT COUNT(*) from <table_name>
This info is from http://www.sql-server-performance.com/
You could use a cursor to loop through the list of tables and stuff the counts into a temp table. Perhaps someone else will have a way to do this without a cursor.
Hope this helps,
CJ "Rick" <ri**@abasoftwa re.com> wrote in message news:28******** *************** ***@posting.goo gle.com... I want to get a resultset of every table in the database, with the current record count of each. What is the easiest way to do this?
I can get the list of tables with:
Select s.name from sysobjects s where xtype = 'U'
each s.name is a table name, but I'm not sure how to join a record count column to the resultset.
Thanks, RickN
Rick (ri**@abasoftwa re.com) writes: I want to get a resultset of every table in the database, with the current record count of each. What is the easiest way to do this?
I can get the list of tables with:
Select s.name from sysobjects s where xtype = 'U'
each s.name is a table name, but I'm not sure how to join a record count column to the resultset.
SELECT 'SELECT ''name'', COUNT(*) FROM ' + name
FROM sysobjects
WHERE xtype = 'U'
AND objectproperty( id, 'IsMSShipped') = 1
ORDER BY name
Cut and paste.
If you want to run it unattended, you can use the stored procedure
sp_MSforeachtab le:
EXEC sp_MSforeachtab le 'SELECT ''?'', COUNT(*) FROM ?'
Note that this procedure is undocumetned.
--
Erland Sommarskog, SQL Server MVP, so****@algonet. se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Thanks everyone for the good ideas.
I've implemented the following and it gets me exactly what I need.
select o.name, i.rows
from sysobjects o, sysindexes i
where i.id = OBJECT_ID(o.nam e)
and i.indid < 2 and o.xtype = 'u'
RickN
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Hunter |
last post by:
I have a largish data set (1000 observations x 100 floating point
variables), and some of the of the data are missing. I want to try a
variety of clustering, neural network, etc, algorithms on the data,
and to keep life simple I want to reduce the dimensions of the matrix
so that I have no missing values, since not all the algorithms are
able to handle them and there is sufficient redundancy in the
variables that I can afford to lose...
|
by: Mike Morton |
last post by:
Runnint Mysql 3.23.47
I have the following two tables:
backorder_notification
->product_code varchar
->email varchar
->date_added date
Products
->code varchar
->name varchar
|
by: Sandros |
last post by:
Background: I'm collecting usability statistics for a group of
applications. Each count has the following attributes: date,
application, major heading, minor heading, count. My intent is
to pull this back as XML and render it in to an HTML table.
I have all this working and all the files are below. I would
value any feedback.
A simple example of the data looks like this:
|
by: JimJim |
last post by:
Wondering if someone here could help me out, I've tried a number of
ways to do this, and while I have managed to get it to work, Im SURE
im not doing the optimal way, and it seems to be causing problems with
my form which is throwing up '#Name? ' in some fields(at seemingly
random times...)
Basicly I have 3 tables, one being the 'top' table, with only 2
fields, a primary key (ID) and a second field Name, this table is
called 'tblDests'
|
by: chudson007 |
last post by:
I need help flagging duplicate records in ome tables I have.
For example if I have Table1 which conatins Field1, Field2 and Field3
like below
Field1 Field2 Field3 Field4
Paul 18 Null Null
Paul 18 Null Null
John 19 Null Null
| |
by: No bother |
last post by:
I have a table which has, among other fields, a date field. I want to
get a count of records where certain criteria are met for, say, three
days in a row. For example:
NumWidgets Date
1 1/1/2000
10 1/2/2000
20 1/3/2000
10 1/4/2000
15 1/5/2000
|
by: jonathan184 |
last post by:
Hi I tried getting this to work through dreamweaver but it did not.
So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me this please.
Thanks for your help in advance. The form and script are on the same page.
<?php require_once('../Connections/rs_ais.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
|
by: kriz4321 |
last post by:
Hi
I have a array in which I need to count the number of ocurrence of a particular word
for eg I need to count no of times a word "test" , "test2" occurs in a array @list.
(The contents of the array is around 100 lines)
Code:
open(FH3, "sample.txt");
while(<FH3>)
|
by: staja84f |
last post by:
I'm trying to locate duplicate data in a table using 4 columns:
employee_id (primary key), employeeid, lastname and firstname.
I can pull up the duplicate data with the last three listed columns,
but when I include the first column (employee_id) in the statement, it
shows nothing, since the employee_id value is unique for each row.
Here's the statement I'm currently using:
select employeeid, firstname, lastname
from empmain
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |