Tuesday, February 20, 2007

SQL Server Reconstruir indices

Enseguida se presenta una solución alternativa para reconstruir los índices de una base de datos. Es un procedimiento simple y muy eficiente en cual tu tienes el control de lo que SQL Server va estar realizando en base de datos.
Solo tendrían que inicializar la variable con el nombre de la base datos y el select de la primer línea con el nombre de su base da datos.

Espero sea útil, y si tienes alguna otra alternativa compártela ! :)


--Cursor to get tables names
declare usertabs cursor for select name from EWIMS_ARCHIVE.dbo.sysobjects where xtype = 'U'
declare @strTableName varchar(255)
declare @strDBName varchar(64)
declare @strFullTableName varchar(255)
set @strDBName = 'EWIMS_ARCHIVE'

-- Used to format messages
declare @crlf varchar (2)
set @crlf = char(13) + char(10)
--Print begin date & time
print getdate()
open usertabs

fetch next from usertabs
into @strTableName
while @@FETCH_STATUS = 0
begin
set @strFullTableName = @strDBName + '.dbo.' + @strTableName
print 'dbreindex ('+ @strFullTableName+ ','''',90) with no_infomsgs'
--Rebuild index(es)for the table
dbcc dbreindex (@strFullTableName,'',90) with no_infomsgs
if @@error <> 0
begin
RAISERROR('An error occurred rebuilding index',11,1)
end
else print 'Index successfully re-built'
print @crlf
fetch next from usertabs
into @strTableName
end
close usertabs
deallocate usertabs
--Print end date & time
print getdate()

Microsoft lanza Service Pack 2 para SQL Server 2005

Microsoft SQL Server 2005, SP 2 habilita a sus clientes tomar ventaja de los nuevas funcionalidades dentro de Windows Vista y Office 2007.
Las areas donde hay mejoras son:
  • Analysis Services
  • Database Engine
  • Integration Services
  • Replication
  • Reporting Services
  • Shared Tools