Thursday, October 25, 2012

SQL Server 2005 Expess – How to fix error 3417


Error:
The SQL Server service could not be started.
I have been getting the error 3417 (SQL Server service terminated with service-specific error 3417…).There was also a reference to the mastlog.ldf file, which is the Master’s database log file.
The database files usually reside on a folder like “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data”. Therefore I checked that the master.mdf and mastlog.ldf were present.

Solution; 

All I had to do, was to add on the “Data” folder (mentioned above) security/permission settings, the “NETWORK SERVICE” account.

Cannot start SQL Server service + SQL Server 2005 Error 3417


When I try to start the Sql Server (MSSQLSERVER) or  Sql Server (SQLEXPRESS) services, get the following error :

Windows could not start the SQL Server (MSSQLSERVER) on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 3417.
After that, I looked at eventvwr. This is the error.
The file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\modellog.ldf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.

SOLUTION :
Go to the folder C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ and select all the files
and right click advanced, uncheck, “Compress contents to save disk space”.
That`s it,piece of cake. Now you can start the services. Try it.

Monday, October 8, 2012

SQL SERVER bottom to top order records hierarchy like parent and childid in a recursive CTE


SQL QUERY FOR TREE HIREARCHY BOTTOM TO TOP
DECLARE @LookupID int
--Our test value
SET @LookupID = 1
WITH cteLevelOne (ParentID, CustID) AS
(
        SELECT   a.ParentID, a.CustID
        FROM     tblCustomer AS a
        WHERE    a.CustID = @LookupID
    UNION ALL
        SELECT   a.ParentID, a.CustID
        FROM     tblCustomer AS a
        INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID
        WHERE c.CustID <> a.CustomerID)
So if tblCustomer looks like this:
ParentID    CustID5            5
1            8
5            4
4            1