You are here: Re: Create Status Table « MsSQL Server « IT news, forums, messages
Re: Create Status Table

Posted by SQL on 05/16/06 22:44

I know what the problem is it's the schema


This will run I just tried it on 2005
this is the change
select table_schema +'.' + table_name from INFORMATION_SCHEMA.TABLES
where table_type =
'base table' order by table_name


use adventureworks


go
create table zzTable_Status (tblname varchar(600),DistinctCount
int,RegularCount int)
Go


DECLARE @tbl varchar(100)
DECLARE @sql varchar(1000)
-- Insert statements for procedure here
declare c_table cursor for
select table_schema +'.' + table_name from INFORMATION_SCHEMA.TABLES
where table_type =
'base table' order by table_name


open c_table
fetch next from c_table into @tbl


while (@@fetch_status = 0)
begin


set @SQL = 'INSERT INTO [zzTable_Status]
SELECT ('''+ @tbl +''') as tblname, count(*),
count(*)
FROM .'+@tbl+''


exec (@SQL)


Print @tbl + ' Updated'


fetch next from c_table into @tbl
end
close c_table
deallocate c_table


select * from zzTable_Status
drop table zzTable_Status

Denis the SQL Menace
http://sqlservercode.blogspot.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация