To choose rebuild or reorganize index process first you need to control index fragmentation status. Execute the code below, SQL Management Studio.
-------------------
Use AdventureWorks
GO
SELECT
ps.object_id,
i.name as IndexName,
OBJECT_SCHEMA_NAME(ps.object_id) as ObjectSchemaName,
OBJECT_NAME (ps.object_id) as ObjectName,
ps.avg_fragmentation_in_percent,
ps.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, 'LIMITED') ps
INNER JOIN sys.indexes i ON i.object_id=ps.object_id and i.index_id=ps.index_id
WHERE avg_fragmentation_in_percent > 5 AND ps.index_id > 0
ORDER BY avg_fragmentation_in_percent desc
---------------------------------------
If the value in "avg_fragmentation percent" column for index is grater than 30 the you should use rebuild else use reorganize.
Rebuild Code
ALTER INDEX [Index name]
ON [ObjectSchemaName].[ObjectName] REBUILD WITH (ONLINE = ON)
----------------------
Reorganize Code
Use AdventureWorks
GO
ALTER INDEX [Index name]
ON [ObjectSchemaName].[ObjectName] REORGANIZE
---------------------------------------
Note : Online index operations can only be performed in Standard or Enterprise edition of SQL Server.
--------------------------------------------------------
You can create a SP by using the code below for automaticly reorganize and rebuild indexes.
CREATE PROC [INDEX_MAINTENANCE] @DBName VARCHAR(100)
AS BEGIN
SET NOCOUNT ON;
DECLARE
@OBJECT_ID INT,
@INDEX_NAME sysname,
@SCHEMA_NAME sysname,
@OBJECT_NAME sysname,
@AVG_FRAG float,
@command varchar(8000),
@RebuildCount int,
@ReOrganizeCount int
CREATE TABLE #tempIM (
[ID] [INT] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[INDEX_NAME] sysname NULL,
[OBJECT_ID] INT NULL,
[SCHEMA_NAME] sysname NULL,
[OBJECT_NAME] sysname NULL,
[AVG_FRAG] float
)
SELECT @RebuildCount=0,@ReOrganizeCount=0
--Get Fragentation values
SELECT @command=
'Use ' + @DBName + ';
INSERT INTO #tempIM (OBJECT_ID, INDEX_NAME, SCHEMA_NAME, OBJECT_NAME, AVG_FRAG)
SELECT
ps.object_id,
i.name as IndexName,
OBJECT_SCHEMA_NAME(ps.object_id) as ObjectSchemaName,
OBJECT_NAME (ps.object_id) as ObjectName,
ps.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL , NULL, ''LIMITED'') ps
INNER JOIN sys.indexes i ON i.object_id=ps.object_id and i.index_id=ps.index_id
WHERE avg_fragmentation_in_percent > 5 AND ps.index_id > 0
and ps.database_id=DB_ID('''+@DBName+''')
ORDER BY avg_fragmentation_in_percent desc
'
exec(@command)
DECLARE c CURSOR FAST_FORWARD FOR
SELECT OBJECT_ID,INDEX_NAME, SCHEMA_NAME, OBJECT_NAME, AVG_FRAG
FROM #tempIM
OPEN c
FETCH NEXT FROM c INTO @OBJECT_ID, @INDEX_NAME, @SCHEMA_NAME, @OBJECT_NAME, @AVG_FRAG
WHILE @@FETCH_STATUS = 0
BEGIN
--Reorganize or Rebuild
IF @AVG_FRAG>30 BEGIN
SELECT @command = 'Use ' + @DBName + '; ALTER INDEX [' + @INDEX_NAME +'] ON ['
+ @SCHEMA_NAME + '].[' + @OBJECT_NAME + '] REBUILD WITH (ONLINE = ON )';
SET @RebuildCount = @RebuildCount+1
END ELSE BEGIN
SELECT @command = 'Use ' + @DBName + '; ALTER INDEX [' + @INDEX_NAME +'] ON ['
+ @SCHEMA_NAME + '].[' + @OBJECT_NAME + '] REORGANIZE ';
SET @ReOrganizeCount = @ReOrganizeCount+1
END
BEGIN TRY
EXEC (@command);
END TRY
BEGIN CATCH
END CATCH
FETCH NEXT FROM c INTO @OBJECT_ID, @INDEX_NAME, @SCHEMA_NAME, @OBJECT_NAME, @AVG_FRAG
END
CLOSE c
DEALLOCATE c
DROP TABLE #tempIM
SELECT cast(@RebuildCount as varchar(5))+' index have been Rebuild,'+cast(@ReOrganizeCount as varchar(5))+' index have been Reorganized.' as Result
END
----------------------------------------------------------
Use the code below for calling SP
exec master.dbo.INDEX_MAINTENANCE 'DBName'
Read more...
Thursday, April 7, 2011
Monday, March 21, 2011
Mailbox stay in disconnected after move mailbox process
Solution
Exchange 2010
Organization Configuration->Mailbox->RightClick to old database->;Properties
Limits Tab-;Set Keep Deleted Mailboxes to Zero (0)
and then on EMS execute the command below;
Clean-MailboxDatabase "Old Database Name"
In order to learn Database name;
Get-mailboxdatabase
Exchange 2007
Server Configuration->Mailbox->RightClick to old database->Properties
Limits Tab->Set Keep Deleted Mailboxes to Zero (0)
and then on EMS execute the command below;
Clean-MailboxDatabase "Old Database Name"
In order to learn Database name;
Get-mailboxdatabase
Exchange 2003
http://support.microsoft.com/kb/940012
Read more...
Exchange 2010
Organization Configuration->Mailbox->RightClick to old database->;Properties
Limits Tab-;Set Keep Deleted Mailboxes to Zero (0)
and then on EMS execute the command below;
Clean-MailboxDatabase "Old Database Name"
In order to learn Database name;
Get-mailboxdatabase
Exchange 2007
Server Configuration->Mailbox->RightClick to old database->Properties
Limits Tab->Set Keep Deleted Mailboxes to Zero (0)
and then on EMS execute the command below;
Clean-MailboxDatabase "Old Database Name"
In order to learn Database name;
Get-mailboxdatabase
Exchange 2003
http://support.microsoft.com/kb/940012
Read more...
Friday, February 25, 2011
The ReportServerVirtualDirectory element is missing.
The session setup from the computer %computername% failed to authenticate.
The cause of this error is the expired computer accound password. By Default computer accounts change password automaticly in every 30 days. If, replication between computer and dc's are not successfull after password changes DC will remove computer account from domain.
You can disable this behaviour from group policy settings,
Setting is under Computer Configuration -> Windows Settings -> Security Settings -> Local Policies/Security Options -> Domain Member: Domain Member: Disable machine account password changesYou should enable this settings.
Read more...
You can disable this behaviour from group policy settings,
Setting is under Computer Configuration -> Windows Settings -> Security Settings -> Local Policies/Security Options -> Domain Member: Domain Member: Disable machine account password changesYou should enable this settings.
Read more...
Tuesday, February 22, 2011
Exchange 2007 Mailbox Sizes
Execute the command on EMS.
Get-MailboxStatistics | Sort-Object TotalItemSize –Descending | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount
You can use toMB or toGB
Read more...
Get-MailboxStatistics | Sort-Object TotalItemSize –Descending | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount
You can use toMB or toGB
Read more...
Event ID 1025 0xc0041800
If you are getting this error on Exchange Server 2007, you should rebuild the indexing catalog.
Content Indexing received an unusual and unexpect error code from MSSearch
Error: 0xc0041800
Execute the command below on Exchange Management Shell
ResetSearchIndex.ps1 [-force] -all
Follow the results from event viewer, you should get Event ID: 110 after successfull process.
Read more...
Content Indexing received an unusual and unexpect error code from MSSearch
Error: 0xc0041800
Execute the command below on Exchange Management Shell
ResetSearchIndex.ps1 [-force] -all
Follow the results from event viewer, you should get Event ID: 110 after successfull process.
Read more...
Wednesday, February 9, 2011
GFI EndPoint Security Installation Error (Process Roll Back)
-->
If you can not install GFI Endpoint Security 4.x , process is rolling back and service can not start;
Apply the steps in link
http://kbase.gfi.com/showarticle.asp?id=KBID003806
Read more...
Apply the steps in link
http://kbase.gfi.com/showarticle.asp?id=KBID003806
Read more...
Subscribe to:
Posts (Atom)