Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with updating statistics

Status
Not open for further replies.

Ed75

MIS
Sep 29, 2004
27
US
I am using the following script to update the stats on my dataabses
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
 
Exact same error, good thought though
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top