SQL Server Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘sql server express’

Error message when you try to install SQL Server 2005 Express Edition or SQL Server 2005 Express Edition with Advanced Services: “Server SQL Server is terminating because of fatal exception c000001d”

Symptoms
When you try toinstall Microsoft SQL Server 2005 Express Edition (SQL Server Express) or Microsoft SQL Server 2005 Express Edition with Advanced Services, the installation fails. Additionally, you receive the following error message:

Server SQL Server is terminating because of fatal exception c000001d.If you examine the SQL Server error log when this problem occurs, you see an error message that resembles one of the following:
Error message 1

SqlDumpExceptionHandler: Process 4 generated fatal exception c000001d EXCEPTION_ILLEGAL_INSTRUCTION. SQL Server is terminating this process.
Error message 2

2006-03-02 22:40:24.79 ServerError: 17311, Severity: 16, State: 1.
2006-03-02 22:40:24.79 ServerSQL Server is terminating because of fatal exception c000001d. This error may be caused by an unhandled Win32 or C++ exception, or by an access violation encountered during exception handling.For more information about how to examine the SQL Server error log, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/ms187885.aspx(http://msdn2.microsoft.com/en-us/library/ms187885.aspx)
Resolution
This problem occurs because of one of the following reasons:The computer on which you try to install SQL Server Express or SQL Server Express with Advanced Services is equipped with a CPU that does not support cache prefetching.
The affected CPUs include VIA Eden CPUs and Transmeta CPUs. Typically, these CPUs are used in devices when low power consumption,low heat, or low noise is important.The media from which you try to install SQL Server Express or SQL Server Express with Advanced Services is corrupted.

How to detect the status of the SQL Server Express service or start the SQL Server Express service by using Visual Basic or Visual C#

Symptoms
Microsoft SQL Server 2005 Express Edition is a service-based product. If you build Microsoft Visual Studio 2005 applications on SQL Server 2005 Express Edition, you can detect the status of the SQL Server Express service when you start the application. You can use the ServiceController class to do the following:Detect the status of the SQL Server Express service.Start the SQL Server Express service if it is not started correctly.Note The default installation of SQL Server 2005 Express Edition uses an instance name of SQLEXPRESS. This instance name maps to the service name of MSSQL$SQLEXPRESS.
Resolution
To use the ServiceController class in a Visual Studio console application to detect and to start the SQL Server Express service, follow these steps: Start Visual Studio 2005.On the File menu, point to New, and then click Project.Click Visual Basic or Visual C# under Project types, and then click Console Application under Visual Studio installed templates.
Note By default, the Module1.vb file is created in the Visual Basic project. By default, the Program.cs file is created in the Visual C# project.Use ConsoleApplication1 as the name in the Name box, and then click OK.Add a reference to the “System.ServiceProcess” namespace. To do this, follow these steps: On the Project menu, click Add Reference.Click the .NET tab, click System.ServiceProcess, and then click OK.Replace the existing code with the following code.
Note Replace the code in the Module1.vb file in the Visual Basic project. Replace the code in the Program.cs file in the Visual C# project.
Visual Basic

Imports SystemImports System.ServiceProcessModule Module1Sub Main()Dim myServiceName As String = “MSSQL$SQLEXPRESS” ’service name of SQL Server ExpressDim status As String’service status (For example, Running or Stopped)Dim mySC As ServiceControllerConsole.WriteLine(“Service: ” & myServiceName)’display service status: For example, Running, Stopped, or PausedmySC = New ServiceController(myServiceName)Trystatus = mySC.Status.ToStringCatch ex As ExceptionConsole.WriteLine(“Service not found. It is probably not installed. [exception=" & ex.Message & "]“)Console.ReadLine()EndEnd TryConsole.WriteLine(“Service status : ” & status)’if service is Stopped or StopPending, you can run it with the following code.If mySC.Status.Equals(ServiceControllerStatus.Stopped) Or mySC.Status.Equals(ServiceControllerStatus.StopPending) ThenTryConsole.WriteLine(“Starting the service…”)mySC.Start()mySC.WaitForStatus(ServiceControllerStatus.Running)Console.WriteLine(“The service is now ” & mySC.Status.ToString)Catch ex As ExceptionConsole.WriteLine(“Error in starting the service: ” & ex.Message)End TryEnd IfConsole.WriteLine(“Press a key to end the application…”)Console.ReadLine()EndEnd SubEnd ModuleVisual C#

using System;using System.Collections.Generic;using System.Text;using System.ServiceProcess;namespace ConsoleApplication1{class Program{static void Main(){string myServiceName = “MSSQL$SQLEXPRESS”; //service name of SQL Server Expressstring status; //service status (For example, Running or Stopped)Console.WriteLine(“Service: ” + myServiceName);//display service status: For example, Running, Stopped, or PausedServiceController mySC = new ServiceController(myServiceName);try{status = mySC.Status.ToString();}catch (Exception ex){Console.WriteLine(“Service not found. It is probably not installed. [exception=" + ex.Message + "]“);Console.ReadLine();return;}//display service status: For example, Running, Stopped, or PausedConsole.WriteLine(“Service status : ” + status);//if service is Stopped or StopPending, you can run it with the following code.if (mySC.Status.Equals(ServiceControllerStatus.Stopped) | mySC.Status.Equals(ServiceControllerStatus.StopPending)){try{Console.WriteLine(“Starting the service…”);mySC.Start();mySC.WaitForStatus(ServiceControllerStatus.Running);Console.WriteLine(“The service is now ” + mySC.Status.ToString());}catch (Exception ex){Console.WriteLine(“Error in starting the service: ” + ex.Message);}}Console.WriteLine(“Press a key to end the application…”);Console.ReadLine();return;}}}Press CTRL+F5 to run the program.

Error message when you try to install SQL Server 2005 Express Edition or SQL Server 2005 Express Edition with Advanced Services: “Server SQL Server is terminating because of fatal exception c000001d”

Symptoms
When you try toinstall Microsoft SQL Server 2005 Express Edition (SQL Server Express) or Microsoft SQL Server 2005 Express Edition with Advanced Services, the installation fails. Additionally, you receive the following error message:

Server SQL Server is terminating because of fatal exception c000001d.If you examine the SQL Server error log when this problem occurs, you see an error message that resembles one of the following:
Error message 1

SqlDumpExceptionHandler: Process 4 generated fatal exception c000001d EXCEPTION_ILLEGAL_INSTRUCTION. SQL Server is terminating this process.
Error message 2

2006-03-02 22:40:24.79 ServerError: 17311, Severity: 16, State: 1.
2006-03-02 22:40:24.79 ServerSQL Server is terminating because of fatal exception c000001d. This error may be caused by an unhandled Win32 or C++ exception, or by an access violation encountered during exception handling.For more information about how to examine the SQL Server error log, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/ms187885.aspx(http://msdn2.microsoft.com/en-us/library/ms187885.aspx)
Resolution
This problem occurs because of one of the following reasons:The computer on which you try to install SQL Server Express or SQL Server Express with Advanced Services is equipped with a CPU that does not support cache prefetching.
The affected CPUs include VIA Eden CPUs and Transmeta CPUs. Typically, these CPUs are used in devices when low power consumption,low heat, or low noise is important.The media from which you try to install SQL Server Express or SQL Server Express with Advanced Services is corrupted.

Error message when you install SQL Server 2005 SP2, SQL Server Express SP2, or SQL Server Express with Advanced Services SP2: “SQL Server Setup failed to execute a command for server configuratio …

Symptoms
When you install Microsoft SQL Server 2005 Service Pack 2 (SP2), SQL Server 2005 Express Edition (SQL Server Express) SP2, or SQL Server Express with Advanced Services SP2, you receive the following error message:

SQL Server Setup failed to execute a command for server configuration.The error was [Microsoft] [SQL Native Client] [SQL Server] CREATE DATABASE failed. Some File names listed could not be created. Check related errorrs.. Refer to the server error logs and Setup logs for detailed error information.Note In this error message, “errorrs” is a misspelling of the word “errors.” Also, the sentence “Check related errorrs..” has two period (.) characters.
Additionally, you experience one of the following symptoms.
Symptom 1When you perform a new installation of SQL Server Express SP2 or of SQL Server Express with Advanced Services SP2, the following error message is logged in the SQLSetup0001_ComputerName_SQL.log file:

SQL Server Setup failed to execute a command for server configuration. The error was [Microsoft] [SQL Native Client] [SQL Server]Incorrect syntax near ‘=’.
[SQL Server]Cannot dump ##MS_AgentSigningCertificate##. SYSDBUPG.SQL terminating.This problem occurs if the length of the installationpath exceeds 58 characters.
Symptom 2When you install SQL Server Express SP2 or SQL Server Express with Advanced Services SP2 on an existing instance of SQL Server Express, the followingerror messages is logged in the SQLSetup0001_ComputerName_SQL.log file:

SQL Server Setup failed to execute a command for server configuration. The error was [Microsoft][SQL Native Client][SQL Server]CREATE DATABASE failed. Some file names listed could not be created. Check related errors.. Refer to the server error logs and Setup logs for detailed error information.Note In this error message, the sentence “Check related errors..” has two period characters.
This problem occurs if the length of the installationpath exceeds 58 characters.
Symptom 3When you install SQL Server 2005 SP2 on an existing instance ofSQL Server 2005 Service Pack 1 (SP1) or on an existing instance of the original release version of SQL Server 2005, the following error message is logged in the SQL9_Hotfix_KB921896_Sqlrun_Sql.msp.log file:

[SQL Server]Incorrect syntax near ‘=’.
[SQL Server]Cannot dump ##MS_AgentSigningCertificate##. SYSDBUPG.SQL terminating.This problem occurs if the length of the installation path exceeds 128 characters.
Resolution
This problem occurs because the script in the Sysdbupg.sql file contains the following code to escape quotations in a file name.

SELECT @certificate_name = QUOTENAME(@certificate_name, ””)The QUOTENAME function returns null if the length of the input value exceeds 128 characters. The longer path name triggers an error in the script.

Problems with SQL Server Express user instancing and ASP.net Web Application Projects

Symptoms
Web applications running on IIS 7.5 and that rely on SQL Server Express user instancing will fail to run using the default IIS 7.5 security configuration on both Windows 7 Client and Windows Server 2008 R2. Developers will encounter problems developing web applications using Visual Studio 2005 + SQL Server Express 2005, Visual Studio 2008 + SQL Server Express 2008, or Visual Studio 2010 + SQL Server Express 2008 on both Windows 7 Client and Windows Server 2008 R2.
Developers will encounter similar problems attempting to develop web application projects (WAP) or websites hosted under IIS6/IIS7/IIS7.5 that rely on SQL Server Express user instances where the WAP project structure or website folder structure exists in a user’s Documents folder.  This issue exists for all versions of Visual Studio regardless of the underlying operating system version.  A web application that attempts to create a database or read/write to a database using SQL Server Express user instance mode can encounter any of the following errors:
An attempt to attach an auto-named database for file c:\Users\[YourUserAccountName]\Documents\Visual Studio 20XX\Projects\[YourSolutionName]\[YourProjectnName]\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
–or–
Failed to generate a user instance of SQL Server due to failure in retrieving the user’s local application data path.  Please make sure the user has a local user profile on the computer. The connection will be closed.
 
NOTE: A web application relies on SQL Server Express’ user instance mode if either of the following is true: The application relies on the default “LocalSQLServer” connection string defined in machine.config The application uses a connection string that contains the following attributes:
            “AttachDBFilename=|DataDirectory|xxxxxx.mdf;User Instance=true”
 
 
Resolution
For Windows Server 2008 R2 and Windows 7
The default security configuration for IIS 7.5 sets application pools to run as the “application pool identity”.  Running an application pool using this special identity was first introduced as an optional setting in Vista SP2 and Windows Server 2008 SP2.  On Windows 7 Client and Windows Server 2008 R2 this special identity is now the default.
 
Web applications built with Visual Studio 2005, Visual Studio 2008, or Visual Studio 2010 and that rely on user instancing with either SQL Server Express 2005 or SQL Server Express 2008 do not work with the new application pool identity.  These products were developed and tested against application pools running with the older NETWORK SERVICE account.
 
For Web Application Projects and Websites Located in a User’s Documents Folder Hosted in IIS
Web application projects (WAP) exist in a folder structure under a user’s “Documents\Visual Studio 20XX\Projects” folder.  Website projects exist in a folder structure under a user’s “Documents\Visual Studio 20XX\Websites” folder.  SQL Server Express user instances require file access rights to the parent folders of the website or WAP project’s directory structure.  Because the IIS service account (NETWORK SERVICE) by default does not have these rights within the Visual Studio project folder structure, WAP projects and websites located in a user’s Documents folder and that are hosted in IIS will not be able to open SQL Server Express user instanced databases for read access.
 
WAPs that were originally created within a user’s Documents folder, but were subsequently changed to use IIS for a web server via the web tab of the project’s properties will encounter this file permissions problem.  Websites hosted in IIS where the website directory structure is located within a user’s Documents folder will also encounter the file permissions problem.  This behavior occurs for WAP projects and websites hosted with any IIS versions that run as NETWORK SERVICE (IIS6, IIS7 and IIS 7.5) where the project structure exists within a user’s Documents folder.