Code Example 1:

select 'update statistics ' + name 
  from sysobjects 
  where type = 'U'
select 'dbcc dbreindex (' + name + ')' 
  from sysobjects 
  where type = 'U'

Code Example 2:

declare @cmd varchar(255)
declare ic insensitive cursor for

select 'dbcc dbreindex (' + name + ')' from sysobjects where type = 'U'
open ic
fetch next from ic into @cmd

while @@fetch_status = 0
begin
    exec (@cmd)
    fetch next from ic into @cmd
end

close ic
deallocate ic