June 9, 2004 at 9:29 am
I need to bring back a list that contains TABLENAME and COUNT with a where clause that is the same on every table (the same column appears in all tables)
Should look like this
table1 2500
table2 123650
etc...................
Any help greatly appreciated. We are having tables where lines are showing as uncommitted inidcated by the common column in the tables.
June 9, 2004 at 11:29 am
SP_MSFOREACHTABLE "select '?', count(column_name) from ?"
June 10, 2004 at 4:00 am
Thanks Nicholas. You are a star.
I can get rid of my 500 line query now and replace it with 1 line.
I could not find anything on BOL.
June 10, 2004 at 5:14 am
sp_msforeachtable is undocumented by Microsoft, but one of the best procs out there....as is it's companion sp_msforeachdb
June 14, 2004 at 2:58 am
I know I am asking for the world, but one other thing.
The code brings back a separate window for each query in QA. I was hoping to bring back the result in one window.
Not too much of a problem, though. More of a nice to have.
June 14, 2004 at 5:27 am
create table #test (tablename varchar(100), count int)
insert into #test exec SP_MSFOREACHTABLE "select '?', count(*) from ?"
select * from #test
--drop table #test
June 14, 2004 at 5:29 am
Thanks again, Nicholas. I completely missed that one. I was looking for something more complicated rather than the obvious.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply