.NET Questions and Solutions

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’

BUG: You may receive an “Access is denied” error message when a query calls an extended stored procedure after you upgrade from SQL Server 2000 to SQL Server 2000 Service Pack 4

Symptoms
After you upgrade a Microsoft SQL Server 2000-based computer to Microsoft SQL Server 2000 Service Pack 4 (SP4), a SQL Server query that calls a registry extended stored procedure may fail, and you receive the following error message:

Access is denied.You receive the error message when you use any one of the registry extended stored procedures in the following list: xp_regreadxp_instance_regreadxp_regenumkeysxp_instance_regenumkeysxp_regenumvaluesxp_instance_regenumvaluesxp_regwritexp_instance_regwritexp_regaddmultistringxp_instance_regaddmultistringxp_regremovemultistringxp_instance_regremovemultistringxp_regdeletevaluexp_instance_regdeletevaluexp_regdeletekeyxp_instance_regdeletekey
Resolution
This problem occurs because SQL Server 2000 SP4 implements a restriction on which registry paths the registry extended stored procedures can access. When a query calls a registry extended stored procedure, the registry extended stored procedure examines the requested registry subkey against a control list of registry hives. If the registry subkey that the query requests is not in the control list, you receive the following error message:

‘Access is denied.’ This error message has nothing to do with the permissions of the SQL Server user account in the context of which one of these registry extended stored procedures is called. The error message occurs even if the user has Administrator permissions.
Note When you receive the error message, the registry extended stored procedure returns no results.

PRB: An Access Violation Occurs If the Sqlsort.dll Version Is Not Compatible with the SQL Server Version

Symptoms
You receive one of the following error messages:When you connect to SQL Server 7.0 from SQL Server Enterprise Manager:

A connection could not be established to <ServerName>.
Reason: SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Please verify SQL Server is running and check your SQL Server registration properties (by right-clicking on the ServerName node) and try again.-Or-When you click Alerts under SQL Server Agent in SQL Server Enterprise Manager:

Error O: SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.Additionally, the Errorlog file in SQL Server 7.0 contains one of the following stack dumps:

SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process..********************************************************************************* BEGIN STACK DUMP:*0x/xx/02 03:12:54 spid 7**Exception Address = 04004697 (Ordinal6 + 297)*Exception Code= c0000005 E*Access Violation occurred writing address 00000004* Input Buffer 54 bytes -*e x e cs p _ M S d b u s e r p r i vN ‘ v e r ‘ * …——-Short Stack Dump0×04004697 Module(sqlsort+4697) (Ordinal6+297)0×005bea83 Module(sqlservr+1bea83) (GetUnicodeRange+e7)0×00575825 Module(sqlservr+175825) (CLikeRangeUtil::LikeRangeTransW+2ec)0×00647680 Module(sqlservr+247680) (CXVariant::LikeRangeStart+7b)0×0056d35b Module(sqlservr+16d35b) (COptExpr::PexprFoldMain+103c)0×00443d71 Module(sqlservr+43d71) (COptExpr::PexprFoldMain+b8)0×00443c08 Module(sqlservr+43c08) (COptExpr::PexprFold+3f)0×004e0d3b Module(sqlservr+e0d3b) (CCvtTree::BuildSte+12e)0×004e0c15 Module(sqlservr+e0c15) (BuildSteFromTree+39)0×004e0b97 Module(sqlservr+e0b97) (CStmtCond::Init+4e)0×00438530 Module(sqlservr+38530) (CCompPlan::FCompileStep+f23)0×0043d00f Module(sqlservr+3d00f) (CProchdr::FCompile+5d9)0×0040ec53 Module(sqlservr+ec53) (CSQLSource::FTransform+234)0×0042140c Module(sqlservr+2140c) (CSQLObject::FTransform2+1ab)0×004e1cdc Module(sqlservr+e1cdc) (CSQLObject::FGetFromDisk+627)0×00420f96 Module(sqlservr+20f96) (CSQLObject::FTransform+21a)0×0040e7b9 Module(sqlservr+e7b9) (CSQLSource::Execute+11d)0×0046225f Module(sqlservr+6225f) (CStmtExec::XretLocalExec+127)0×0046211e Module(sqlservr+6211e) (CStmtExec::XretExecute+253)0×0040f487 Module(sqlservr+f487) (CMsqlExecContext::ExecuteStmts+11b)0×0040ef35 Module(sqlservr+ef35) (CMsqlExecContext::Execute+16b)—————————————————————————Error: 0, Severity: 19, State: 0language_exec: Process 7 generated an access violation. SQL Server is terminating this process. -Or-

********************************************************************************* BEGIN STACK DUMP:*0x/xx/02 16:49:07 spid 7**Exception Address = 105B498A*Exception Code= c0000005 E*Access Violation occurred reading address FFFFFFFF* Input Buffer 54 bytes -*e x e cs p _ M S d b u s e r p r i vN ‘ v e r ‘ ………Short Stack Dump0×105b498a Module(UNKNOWN+0)—————————————————————————Error: 0, Severity: 19, State: 0language_exec: Process 7 generated an access violation. SQL Server is terminating this process.***************************************************************************** BEGIN STACK DUMP:*0x/xx/02 16:47:50 spid 7**Exception Address = 105B48FA*Exception Code= c0000096 E* Input Buffer 188 bytes -*E X E C U T Em s d b . d b o . s p _ h e l p _ a l e r t@ o r d e *r _ b y=N ‘ s e v e r i t yA S C ,m e s s a g e _ i dA S *C ,d a t a b a s e _ n a m eD E S C ‘ *—————————————————————————Short Stack Dump0×105b48fa Module(UNKNOWN+0)—————————————————————————Error: 0, Severity: 19, State: 0language_exec: Process 7 generated an access violation. SQL Server is terminating this process.
Resolution
This behavior occurs if the versions of Sqlsort.dll and Sqlservr.exe are not compatible.

FIX: An EXCEPTION_STACK_OVERFLOW exception may occur when you try to run a Transact-SQL query in SQL Server 2005

Symptoms
This article describes the following about this hotfix release: The issues that are fixed by this hotfix packageThe prerequisites for applying the hotfix packageWhether you must restart the computer after you apply the hotfix packageWhether the hotfix package is replaced by any other hotfix packageWhether you must make any registry changes after you apply the hotfix packageThe files that are contained in the hotfix package
Resolution
When you try to run a Transact-SQL query in Microsoft SQL Server 2005, an EXCEPTION_STACK_OVERFLOW exception may occur. When this problem occurs, the SQL Server service may stop unexpectedly.
Note This problem may only occur in SQL Server 2005 x64 editions.

How to enable SQL Server connectivity on Windows XP Service Pack 2

Symptoms
This article describes how to enable SQL Server connectivity on Windows XP Service Pack 2.
By default, Windows Firewall is enabled on computers that are running Microsoft Windows XP Service Pack 2. Windows Firewall closes ports such as 445 that are used for file and printer sharing to prevent Internet computers from connecting to file and print shares on your computer or to other resources. When SQL Server is configured to listen for incoming client connections by using named pipes over a NetBIOS session, SQL Server communicates over TCP ports and these ports must be open. SQL Server clients that are trying to connect to SQL Server will be not be able to connect until SQL Server is set as an exception in Windows Firewall. To set SQL Server as an exception in Windows Firewall, use the steps that are listed in the “More Information” section.
Resolution
Create an exception for each instance of SQL Server The following method will open User Datagram Protocol (UDP) port 1434 in addition to the Transmission Control Protocol (TCP) port. If you want to open these ports manually, see the following article in the Microsoft Knowledge Base:
841252?(http://support.microsoft.com/kb/841252/) How to manually enable TCP/IP on Windows XP Service Pack 2 for SQL Server 2000
Note If you are running multiple instances of SQL Server, you will have to create an exception for each instance. Click Start, and then click Run. In the Run dialog box, type Firewall.cpl, and then click OK.In the Windows Firewall dialog box, click Add a Program on the Exceptions tab.In the Add Program dialog box, you can select an instance of SQL Server or you can click the Browse button to locate the instance of SQL Server that you want to add to the exception list. The default installation locations for SQL Server are listed in the following table.

Collapse this tableExpand this table
VersionFile pathSQL Server 7.0 Mssql\Binn\Sqlservr.exeSQL Server 2000 Default InstanceProgram Files\Microsoft SQL Server\Mssql\Binn\Sqlservr.exeSQL Server 2000 Named InstanceProgram Files\Microsoft SQL Server\Mssql$instancename\Binn\Sqlservr.exeSQL Server 2005 Default InstanceProgram Files\Microsoft SQL Server\MSSQL.x\MSSQL\Binn\sqlservr.exeSQL Server 2005 Named InstanceProgram Files\Microsoft SQL Server\MSSQL.x\MSSQL\Binn\sqlservr.exe
Note Each SQL Server 2005 instance is made up of a distinct set of services with specific settings for collations and other options. The directory structure, registry structure, and service names all reflect the specific instance ID of the SQL Server instance that is created during SQL Server 2005 Setup. x is the instance ID of the SQL Server instance that is created during SQL Server 2005 Setup.Select the name of the instance, and then click OK.Under Programs and Services, select the check box that is next to the name you selected in step 6, and then click OK. How to use Multiprotocol Remote Procedure Call (RPC)If you are using Multiprotocol, you must perform the steps in the “Create an exception for each instance of SQL Server” section as well as open the correct TCP ports on Windows Firewall.How to run RPC over TCPWarning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.
To run RPC over TCP, follow these steps:Enable port 135 on Windows Firewall. To do this, follow these steps: Click Start, and then click Run.In the Run dialog box, type Firewall.cpl, and then click OK.On the Exceptions tab, click Add Port. In the Port number box, type 135, and then click the TCP button.In the Name box, type a name for the port such as MULTI, and then click OK.On the Exceptions tab, you will see the new service. To enable the port, click to select the check box next to your new service, and then click OK.Modify the \\HKLM\SOFTWARE\Policies\Microsoft\Windows NT\RPC registry key.
Note If you have just installed SQL Server, this registry key does not exist. You will have to create the key and set the value. To do this, follow these steps: Click Start, and then click Run.In the Run dialog box, type Regedit, and then click OK. This will start Registry Editor.Locate the \\HKLM\SOFTWARE\Policies\Microsoft\Windows NT\RPC Registry key.Set the RestrictRemoteClients key to 0. Quit Registry EditorRestart the computer that is running SQL Server.How to use RPC over Named PipesIf you are running RPC over Named Pipes, you must open port 445 on Windows Firewall. To do this, follow these steps: Click Start, and then click Run.In the Run dialog box, type Firewall.cpl, and then click OK.On the Exceptions tab, click Add Port. In the Port number box, type 445, and then click the TCP button.In the Name box, type a name for the port such as MULTI, and then click OK.On the Exceptions tab, you will see the new service. To enable the port, click to select the check box next to your new service, and then click OK.

FIX: A NullReferenceException error for T-SQL Debugger occurs when you use the SET SHOWPLAN_XML ON option in a Transact-SQL statement on a instance of SQL Server 2008

Symptoms
When you run a Transact-SQL script that uses the SET SHOWPLAN_XML ON option in the debugging mode on an instance ofMicrosoft SQL Server 2008, aNullReferenceException error for T-SQL Debugger occurs.
Resolution
This issue occurs when a call to SQL Server Management Objects (SMO) is made from a connection context in which you use the SET SHOWPLAN_XML ON option together with T-SQL Debugger. T-SQL Debugger uses the Server object in SMO to retrieve the version of the instance ofSQL Server that is connected. T-SQL Debugger uses this information to impose the version restriction. This is a known issue associated with T-SQL Debugger.

FIX: A floating point exception occurs during the optimization of a query

Symptoms
An INSERT, UPDATE, or DELETE query that operates on a table that is referenced by an indexed view may encounter a floating point exception during optimization. The batch and transaction is aborted, and you receive the following error message:

Server: Msg 3628, Level 16, State 1, Line 1
A floating point exception occurred in the user process. Current transaction is canceled.
Resolution
Service pack informationTo resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/) How to obtain the latest SQL Server 2000 service pack
Hotfix informationThe English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

DateTimeVersionSizeFile name——————————————————————-31-May-200317:452000.80.818.078,400Console.exe25-Jun-200300:012000.80.818.033,340Dbmslpcn.dll25-Apr-200301:12786,432Distmdl.ldf25-Apr-200301:122,359,296Distmdl.mdf30-Jan-200300:55180Drop_repl_hotfix.sql12-Sep-200302:262000.80.859.01,905,216Dtspkg.dll26-Aug-200319:162000.80.854.0528,960Dtspump.dll23-Jun-200321:402000.80.837.01,557,052Dtsui.dll23-Jun-200321:402000.80.837.0639,552Dtswiz.dll24-Apr-200301:51747,927Instdist.sql03-May-200300:561,581Inst_repl_hotfix.sql08-Feb-200305:402000.80.765.090,692Msgprox.dll01-Apr-200301:071,873Odsole.sql05-Apr-200300:462000.80.800.062,024Odsole70.dll07-May-200319:412000.80.819.025,144Opends60.dll02-Apr-200320:482000.80.796.057,904Osql.exe02-Apr-200322:152000.80.797.0279,104Pfutil80.dll04-Aug-200317:17550,780Procsyst.sql11-Sep-200323:3712,305Qfe469315.sql22-May-200321:5719,195Qfe469571.sql06-Sep-200300:361,090,932Replmerg.sql06-Sep-200306:182000.80.858.0221,768Replprov.dll06-Sep-200306:182000.80.858.0307,784Replrec.dll05-Sep-200323:001,087,150Replsys.sql13-Aug-200315:28986,603Repltran.sql29-Jul-200319:132000.80.819.0492,096Semobj.dll31-May-200317:272000.80.818.0172,032Semobj.rll05-Aug-200320:06127,884Sp3_serv_uni.sql01-Jun-200300:012000.80.818.04,215,360Sqldmo.dll07-Apr-200316:4425,172Sqldumper.exe19-Mar-200317:202000.80.789.028,672Sqlevn70.rll01-Jul-200323:182000.80.834.0180,736Sqlmap70.dll03-Sep-200301:562000.80.857.0188,992Sqlmmc.dll02-Sep-200322:032000.80.857.0479,232Sqlmmc.rll08-Feb-200305:402000.80.765.057,920Sqlrepss.dll23-Sep-200300:032000.80.863.07,614,545Sqlservr.exe25-Jul-200320:442000.80.845.0590,396Sqlsort.dll08-Feb-200305:402000.80.765.045,644Sqlvdi.dll25-Jun-200300:012000.80.818.033,340Ssmslpcn.dll01-Jun-200300:012000.80.818.082,492Ssnetlib.dll01-Jun-200300:012000.80.818.025,148Ssnmpn70.dll01-Jun-200300:012000.80.818.0158,240Svrnetcn.dll31-May-200317:592000.80.818.076,416Svrnetcn.exe30-Apr-200322:522000.80.816.045,132Ums.dll01-Jul-200323:192000.80.834.098,816Xpweb70.dll Note Because of file dependencies, the most recent hotfix or feature that contains these files may also contain additional files.