declare @dbname varchar(50)
select @dbname ='WebFZ'
create table #tableT(tn sysname)
insert into #tableT exec ('select name from '+@dbname+'..sysobjects where xtype = '+''''+'U'+'''')
declare tableCrusor cursor for select tn from #tableT
open tableCrusor
declare @table sysname
fetch next from tableCrusor into @table
while @@fetch_status = 0
begin
set @table = @dbname+'.dbo.'+@table
dbcc dbreindex (@table)
fetch next from tableCrusor into @table
end
close tableCrusor
deallocate tableCrusor