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 ‘procedure’

FIX: AV When You Call MSXML 2.6 Parser from a Stored Procedure

Symptoms
When you use the MSXML 2.6 parser from a stored procedure, you may encounter an access violation in the parser (Msxml2.dll). This particular exception is characterized by the call stack shown in the “More Information” section of this article.
Resolution
This is an issue with the garbage collection subsystem of MSXML2.

FIX: Merge Agent Fails with a “The remote procedure call failed and did not execute” Error

Symptoms
The merge agent fails with the following error message:

The remote procedure call failed and did not executeThe task reports the preceding remote procedure call (RPC) failure in its history, which can be misleading because there are not any other connectivity problems. The merge agent runs into a handled exception with the following stack, as seen in the replication exception log file:

The Exception Stack Dump follows:
ntdll77f67546RtlpWaitForCriticalSection
ntdll41d70871RtlEnterCriticalSection
replrec41d68839CReconcilerHistory::AddMessage
replrec41d666c8CDatabaseReconciler::LogProgressMessage
replrec41d66362CDatabaseReconciler::ProcTombstones
replrec41d65449CDatabaseReconciler::MoveChangesToDest
replrec00403819CDatabaseReconciler::Reconcile
replmerg004038e2CReconcilerTask::Reconcile
replmerg00407af8AgentRun
replmerg08ec83ecAgentMain

Resolution
The RPC failed message is the result of a exception with the merge agent. Replmerg.exe fails while inserting generation history, generating an exception when completely filling the allocated memory buffer. This causes an out of space situation and the required null termination character cannot be added, subsequently causing the access violation.

FIX: Error message when you run a stored procedure that references a linked server that is linked to the local server itself in SQL Server 2005: “Transaction context in use by another session”

Symptoms
In SQL Server 2005, you create a linked server that is linked to the local server itself. This configuration is also known as a loopback linked server. Then, you create a stored procedure that contains a statement that resembles the following statement:

INSERT <LocalTable> EXEC <LinkedServer>.<ProcedureName>When you run the stored procedure, you receive the following error message:

Msg 3910, Level 16, State 2, Line 1
Transaction context in use by another session.Note This problem does not occur in Microsoft SQL Server 2000.
Resolution
This problem occurs because of a design change in SQL Server 2005.

FIX: Cannot Use Dynamic SQL Statements Within OPENQUERY

Symptoms
An Access Violation (AV) may occur if you use the OPENQUERY function to execute a stored procedure that has these properties:The stored procedure has a dynamic SQL statement that uses an OPENQUERY function.
You execute the dynamic SQL statement by using the sp_executesql stored procedure.
Resolution
The Access Violation occurs because SQL Server cannot determine the metadata correctly. SQL Server uses SET FMTONLY ON to obtain the metadata of the string inside the OPENQUERY function. With a SET FMTONLY ON statement, the remote server cannot execute the statement and it simply compiles the statement to get the metadata returned by the statements within the stored procedure. If the statements are dynamic, there is no way for the Distributed Query Processor to determine the metadata at compile time because the value of the string is not known until execution time.

FIX: A memory leak occurs when you use the sp_OAMethod stored procedure or the sp_OAGetProperty stored procedure to call a method of a COM object in SQL Server 2005

Symptoms
This article describes the following about this hotfix release:The issues that are fixed by the hotfix packageThe prerequisites for installing the hotfix packageWhether you must restart the computer after you install the hotfix packageWhether the hotfix package is replaced by any other hotfix packageWhether you must make any registry changesThe files that are contained in the hotfix package
Resolution
In Microsoft SQL Server 2005, when you call a method of a component object model (COM) object by using the sp_OAMethod stored procedure or the sp_OAGetProperty stored procedure, a memory leak occurs. For the sp_OAMethod stored procedure, this problem occurs if the method returns the result in the output parameter of the method. For the sp_OAGetProperty stored procedure, this problem occurs if the stored procedure returns a property value in the OUTPUT parameter.
Additionally, if the memory leaks exhausts the non-buffer pool memory region, the following error message is logged in the SQL Server error log file:

2008-05-01 08:35:07.80 spid535 Downgrading backup log buffers from 1024K to 64K
2008-05-06 09:35:22.55 spid77 Failed Virtual Allocate Bytes: FAIL_VIRTUAL_RESERVE 1048576
2008-05-06 10:48:04.85 spid593 Error: 701, Severity: 17, State: 123.
2008-05-06 10:48:04.85 spid593 There is insufficient system memory to run this query.