July 11, 2011 at 7:46 am
DECLARE @TableName sysname
DECLARE cur_reindex CURSOR FOR
SELECT table_name
FROM information_schema.tables
WHERE table_type = 'base table'
OPEN cur_reindex
FETCH NEXT FROM cur_reindex INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Reindexing ' + @TableName + ' table'
DBCC DBREINDEX (@TableName, ' ', 90)
FETCH NEXT FROM cur_reindex INTO @TableName
END
CLOSE cur_reindex
DEALLOCATE cur_reindex
above query is throwing error like "Could not find a table or object named 'Client_102680ENG9886'. Check sysobjects."
Reason for this is there are tables with owner apart from 'dbo'.
Kindly give me query to reindex all the tables in database which is having owner(schema) apart from dbo
July 11, 2011 at 8:36 am
Have a look through the Scripts section of this web site. Here's one that I found on a quick search: http://www.sqlservercentral.com/scripts/Administration/72594/
July 11, 2011 at 9:27 am
I recommend using either Ola Hallengren's maintenance script for re-indexing or Michelle Ufford's script[/url]
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply