# Database Discussions > Microsoft SQL Server 2005 >  Reindexing Job Failure

## gurubhai

Hi
I am working on SQL Server 2005.
I have created a job for reindexing as follows:


declare @object_name nVarchar(512) 
declare  Reindex_All_Tables cursor
for

select distinct o.name  from sys.objects o 
inner join sys.indexes i
on i.object_id=o.object_id
where i.object_id>100 and i.type_desc not like 'heap' 

open Reindex_All_Tables
fetch next from Reindex_All_Tables
into @object_name 
while @@fetch_status = 0
begin
dbcc dbreindex(@object_name) --with no_infomsgs
if @@error <> 0
  break
print 'Finished Indexing: ' + @object_name
fetch next from Reindex_All_Tables
into @object_name 
end
close Reindex_All_Tables
deallocate Reindex_All_Tables

But this job is failing!!!!
So when i try to execute the above written query manually, i get the following result:

DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Finished Indexing: tablename1
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Finished Indexing: tablename2
and so on....
and in the end i am getting below error message:
Msg 2501, Level 16, State 45, Line 16
Cannot find a table or object with the name "queue_messages_1977058079". Check the system catalog.

Could you help me with this???

----------


## rmiao

Try select user tables only in following:

select distinct o.name from sys.objects o 
inner join sys.indexes i
on i.object_id=o.object_id
where i.object_id>100 and i.type_desc not like 'heap' 
AND O.TYPE = 'U'

----------


## gurubhai

Thanks a lot for ur reply!!
Sure using only user tables worked!!
But i couldn't understand the error!!!
I read that these are some internal tables but i have no idea what these do and how come the error say that it could not find the table when it is there!!!
 :Confused:

----------


## rmiao

It's message queue used by service broker.

----------

