|
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]
|