Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
shawnrusin
Starting Member
2 Posts |
Posted - 2004-08-10 : 14:14:59
|
| I need to do a select count(*) from tablebut I want my table name to show up too with my returnd rowsso if I do select count(*) from tablei get5677 rowsbut i wanttable 5677 rows or 5677 tableso im looking for some thing likeselect count(*) from table1 and show table1 nameunion allselect count(*) from table2 and show table2 nameunion allselect count(*) from table3 and show table3 name---------------------------------------------------------5677 : table156 : table2777 : table3---------------------------------------------------------3 rows in set (0.00) secShawn RusinMCSE/MCDBA |
|
|
ffoiii
Starting Member
12 Posts |
Posted - 2004-08-10 : 14:42:25
|
| select count(*), 'Table1' from Table1 union allselect count(*), 'Table2' from Table2 union allselect count(*), 'Table3' from Table3ffoiii |
 |
|
|
Pat Phelan
Posting Yak Master
187 Posts |
Posted - 2004-08-10 : 16:28:38
|
This is only good after you update the statistics, but you could use:DBCC UPDATEUSAGE (0) WITH COUNT_ROWSSELECT rows, Object_Name(id) FROM dbo.sysindexes WHERE indid IN (0, 1) -PatP |
 |
|
|
shawnrusin
Starting Member
2 Posts |
Posted - 2004-08-10 : 17:06:59
|
| thanks that works for me!Shawn RusinMCSE/MCDBA |
 |
|
|
|
|
|