I am using the following script to update the stats on my dataabses
One one database I am getting an error stating that the table does not exist. The table does indeed exist and if I omit that table from my script it goes to the next line of the sysobjects table and then tells me that the next table does not exist.
Any Ideas?
Thanks,
Ed
Code:
DECLARE @table_name varchar(1000),@sql nvarchar(4000)
declare c1 cursor for SELECT name
FROM sysobjects
WHERE xtype = 'U'
open c1
fetch next from c1 into @table_name
while @@Fetch_Status = 0
begin
Select @sql = 'UPDATE STATISTICS '+ @table_name +' WITH FULLSCAN'
--print @sql
exec sp_executesql @sql
fetch next from c1 into @table_name
end
close c1
deallocate c1
GO
One one database I am getting an error stating that the table does not exist. The table does indeed exist and if I omit that table from my script it goes to the next line of the sysobjects table and then tells me that the next table does not exist.
Any Ideas?
Thanks,
Ed