parameter. If you run this script repeatedly on a new connection to SQL Server 2005, a memory leak occurs every time.
DECLARE @object int;
DECLARE @hr int;
DECLARE @src varchar(255), @desc varchar(255);
EXEC @hr = sp_OACreate 'SQLDMO.SQLServer', @object OUT;
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
RETURN
END
EXEC @hr = sp_OASetProperty @object, 'LoginSecure', 'TRUE'
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object
RETURN
END
EXEC @hr = sp_OAMethod @object, 'Connect', NULL, '<ComputerName>\<InstanceName>'
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object
RETURN
END
DECLARE @property varchar(255)
EXEC @hr = sp_OAMethod @object, 'HostName', @property OUT
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object
RETURN
END
PRINT @property
EXEC @hr = sp_OAGetProperty @object, 'HostName', @property OUT
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object
RETURN
END
PRINT @property
EXEC @hr = sp_OADestroy @object
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object
RETURN
END
Additionally, you may experience an access violation because the problemthat is described in the "Symptoms" section occurs. The SQL error log file will include the following information:
The fix for this problem is in the Odsole70.dll file. The first fixed version of the binary is 2005.90.2232.0.
Microsoft SQL Server 2005 Service Pack 2 (SP2) does not include this fixed binary. If you experience this problem in SQL Server 2005 SP2, you must install a cumulative update to fix this problem.
The first cumulative update that includes this fix is Cumulative update package 2 for SQL Server 2005 SP2. The build for this update is 09.00.3175. Therefore, you can install the latest cumulative update for SQL Server 2005 or any cumulative update that was released after June 2007 to resolve this issue.