Sunday, September 18, 2011

Failed To Open Discovery On Machine: 'xxxxx'

SQL Server 2005 setup fails with the following errors in the setup log:
Failed to find property "ComputerList" {"SqlComputers", "", ""} in cache
Failed to open discovery on machine: 'xxxxxx'

Resolution:
Check network properties to see if "File and Printer sharing" is enabled. If not, enable it and attempt the installation again.

Installation Package for the Product Microsoft SQL Server Native Client cannot be found

SQL Server 2005 installation fails with the following error:
An installation package for the product Microsoft SQL Server Native Client cannot be found. Try the installation again using a valid copy of the installation package 'sqlncli.msi'
 Resolution:
Search for the file 'sqlncli.msi' in the installation CD / folder, double click it and select uninstall. Restart the installation.

Sunday, September 11, 2011

Error 5184: Cannot use file 'xxxxx' for clustered server


This error occurs when the disk that you're trying to restore/attach the database file to does not have a dependency on the SQL Server resource in the cluster. It isn't enough to have the resource in the same cluster group.

Resolution:
Take the cluster group offline, add the disk dependency to the SQL Server resource, then bring the cluster group back online.

Thursday, September 8, 2011

Identifying Fragmented Indexes

Code to identify all fragmented indexes in a SQL Server instance:


/****** Object:  StoredProcedure [dbo].[usp_getFRAG]    Script Date: 09/09/2011 05:22:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
Author: Eugene Teh
Last Update: 9th Sept 2011
Name: usp_getFRAG
*/
CREATE PROCEDURE [dbo].[usp_getFRAG]
@fragPercent int, --Percentage of fragmentation
@pageCount int  --Number of index pages
AS
SELECT
FRAG.[database_id],
    OBJECT_SCHEMA_NAME(FRAG.[object_id]) + '.' + OBJECT_NAME(FRAG.[object_id]),
    SIX.[Name],
    FRAG.Avg_fragmentation_in_percent,
    FRAG.Page_count
FROM
    sys.dm_db_index_physical_stats
    (
        NULL,    --Returns stats for all DB in instance
        0,          --Parameter for object_id.
        DEFAULT,    --Parameter for index_id.
        0,          --Parameter for partition_number.
        DEFAULT     --Scanning mode. Default to "LIMITED"
    ) FRAG
    JOIN
    sys.indexes SIX ON FRAG.[object_id] = SIX.[object_id] AND FRAG.index_id = SIX.index_id
WHERE
FRAG.avg_fragmentation_in_percent > @fragPercent AND
FRAG.page_count > @pageCount
ORDER BY
    FRAG.avg_fragmentation_in_percent DESC;