| Author |
Topic |
|
kneel
Starting Member
36 Posts |
Posted - 2008-02-26 : 09:06:00
|
| Hi,Does anyone know how to calcuate total no of rows of all tables from database in single query?Thanks in advance--kneel |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-26 : 09:10:45
|
Yes. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
kneel
Starting Member
36 Posts |
Posted - 2008-02-26 : 09:12:48
|
| can u please help me ?Thanks in advance--kneel |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-26 : 09:19:27
|
[code]CREATE TABLE #Temp (TableName VARCHAR(400), Records INT);INSERT #TempEXEC sp_msforeachtable 'SELECT ''?'' AS TableName, COUNT(*) AS Records FROM ?'SELECT * FROM #TempDROP TABLE #Temp[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
kneel
Starting Member
36 Posts |
Posted - 2008-02-26 : 09:23:36
|
| Thanks a lot .....--kneel |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-26 : 09:32:07
|
| DBCC UPDATEUSAGE('DBNAME') WITH COUNT_ROWSselect object_name(id) as table_name,rows from sysindexeswhere indid<2order by 1MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-26 : 09:46:23
|
Does this work if there is no index in a table? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-02-26 : 09:51:48
|
| Peso,I liked you script.CREATE TABLE #Temp (TableName VARCHAR(400), Records INT);INSERT #TempEXEC sp_msforeachtable 'SELECT ''?'' AS TableName, COUNT(*) AS Records FROM ?'SELECT * FROM #TempDROP TABLE #Temp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-26 : 11:00:37
|
quote: Originally posted by Peso Does this work if there is no index in a table? E 12°55'05.25"N 56°04'39.16"
YESMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-26 : 11:02:29
|
quote: Originally posted by sodeep Peso,I liked you script.CREATE TABLE #Temp (TableName VARCHAR(400), Records INT);INSERT #TempEXEC sp_msforeachtable 'SELECT ''?'' AS TableName, COUNT(*) AS Records FROM ?'SELECT * FROM #TempDROP TABLE #Temp
Note that sp_msforeachtable is undocumentedMadhivananFailing to plan is Planning to fail |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-02-26 : 11:55:04
|
quote: Originally posted by madhivanan DBCC UPDATEUSAGE('DBNAME') WITH COUNT_ROWSselect object_name(id) as table_name,rows from sysindexeswhere indid<2order by 1MadhivananFailing to plan is Planning to fail
I have seen cases where sysindex tab doesn't have the correct count. |
 |
|
|
|