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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Stats Question

Status
Not open for further replies.

Ed75

MIS
Sep 29, 2004
27
US
I am currently using the following script to update stats on all of my databases.

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 of my databases is coming up saying

Msg 2706, Level 16, State 6, Line 1
Table 'HEATSym' does not exist.

Do I have a problem with this database?
 
Does that table exist?

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Is there a space in the name or something that requires [] to be placed around the object name (which I'd recommend doing anyway)?

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
wouldn't this be much easier?

Code:
sp_MSforeachtable @command1="UPDATE STATISTICS ? WITH FULLSCAN""

- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top