SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sp_MSforeachtable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 03/14/2013 :  08:39:51  Show Profile  Reply with Quote
Hi all

I'm trying to sort out stats and indexes on our server and I'm running a test on 3 tables to start with (three of our biggest).
I've got the stats bit sorted, but I can't get the code to rebuild the indexes on the 3 specific tables.
This is the code I'm using:-

exec sp_updatestats
exec sp_MSforeachtable '
if  in (''FACT_iApplicationStat'',''FACT_iAgentBySkillsetStat'',''FACT_iAgentPerformanceStat'')
	begin
		ALTER INDEX ALL ON  REBUILD
	end

'

I'm getting the following error:-
Msg 207, Level 16, State 1, Line 2
Invalid column name '[dbo].[FACT_iApplicationStatSummary]'.
when it starts the index rebuild.

Can anyone see where I'm going wrong?
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000