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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 designing metrics with a stored proc

Author  Topic 

elpeak
Starting Member

5 Posts

Posted - 2007-09-12 : 09:21:09
I want to build metrics on my current table and the historic tables. I want a proc that will do a select count on the tables and email me the results, also insert the results in a table. I can expand different metrics from that point. I've got ideas, but looking for a template that's better than what i have. Thanks

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-09-12 : 17:43:41
You can use sp_MSForEachTable stored procedure to do this. For example:

use pubs
go
create table #rowcount (tablename varchar(128), rowcnt int)
exec sp_MSforeachtable
'insert into #rowcount select ''?'', count(*) from ?'



Future guru in the making.
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2007-09-12 : 21:52:47
Have you looked into utilizing the DMVs that come w/ 2005?


Nathan Skerl
Go to Top of Page

mohit_sme
Starting Member

13 Posts

Posted - 2007-09-13 : 15:41:28
This might be useful

http://mohitnayyar.blogspot.com/2007/08/table-row-count-using-3-different-ways.html


Thanks
Mohit Nayyar
http://mohitnayyar.blogspot.com
Go to Top of Page
   

- Advertisement -