SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DBCC REINDEX all user tables


DBCC REINDEX all user tables

Author
Message
david wootton
david wootton
SSC-Enthusiastic
SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)SSC-Enthusiastic (132 reputation)

Group: General Forum Members
Points: 132 Visits: 1
Comments posted to this topic are about the item DBCC REINDEX all user tables



tpelegrin
tpelegrin
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 0
Hi, I have recently try to execute it using SQL Server 2000 but with no success, the erros message is :

Serveur : Msg 207, Niveau 16, État 3, Ligne 24
'origfillfactor' : nom de colonne incorrect.
Serveur : Msg 207, Niveau 16, État 1, Ligne 24
'origfillfactor' : nom de colonne incorrect.

Whistling
davidw
davidw
SSC Rookie
SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)

Group: General Forum Members
Points: 28 Visits: 179
Check to make sure you have delared the variable it is complaing about
@STLSQLGuy
@STLSQLGuy
SSC-Addicted
SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)

Group: General Forum Members
Points: 446 Visits: 209
This is still 95% his code but I modified it a little to work with databases that have schemas other than DBO. It also uses the newer 2005 tables instead of SYSOBJECTS. I needed to use this to work with a JD Edwards implementation. Thanks Mr. Wootton.
-------------------------------------------------------------------------------------------------

drop table #tmp

declare @msg varchar(500)

select x.name,
x.object_id AS id,
y.name AS sch
into #tmp
from sys.tables x, sys.schemas y
where type = 'U'
and y.schema_id = x.schema_id
and x.name LIKE 'F%' -----you can omit this line, all my real tables started with F


declare reindexcursor cursor for

select #tmp.name,
sysindexes.origfillfactor,
#tmp.sch
from sysindexes, #tmp
where sysindexes.id = (select #tmp.id
from #tmp
where #tmp.id=sysindexes.id)
group by #tmp.name,sysindexes.origfillfactor,#tmp.sch
having count(#tmp.name) >= 1
order by 1

open reindexcursor


declare @tname varchar(100)
declare @ffact varchar(10)
declare @tsch varchar(10)


fetch next from reindexcursor into @tname,@ffact,@tsch

WHILE (@@FETCH_STATUS <> -1)

BEGIN

IF (@@FETCH_STATUS <> -2)

BEGIN

print ' '
SELECT @msg = 'DBCC DBREINDEX ('''+@tsch+'.'+@tname+''', '' '','+(@ffact)+')'
print @msg
exec (@msg)
print ' '

END

FETCH NEXT FROM reindexcursor INTO @tname, @ffact,@tsch

END

CLOSE reindexcursor
DEALLOCATE reindexcursor
GO


thanks, ERH

SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)

Group: General Forum Members
Points: 69617 Visits: 18570
Nice change and thanks for sharing.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search