Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2005, 04:08 AM
Authorized User
 
Join Date: Jun 2003
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hanging process

Hi all.

I have a SP that has worked for a long time, but now it has stopped working. In the SP I simply move data from one table on one server, to another table on another (physical) server. The trouble started when we moved the target database to a new physical server.

Now when the SP is started, it seems to be running OK, but it does no work at all. If I kill the process, it says it is rolling back, but it never completes. (KILL WITH STATUSONLY reports that it is 100% rolled back, but the process is hanging on...)

I use some manual transaction handling in the SP, and if I remove this it works fine. It puzzles me though why it worked on the old server. See code below. Any comments welcome.


Code in SP:
Code:
SET XACT_ABORT ON

IF @@TRANCOUNT<>0 ROLLBACK --Check for orphaned trans and rollback

DECLARE @errorcode int
set @errorcode=0

BEGIN TRAN 
--Overfør verdier
insert into Lnk_TargetServer.[Axapta].[dbo].[TargetTable]([ANLEGGSID], [VOLUM], [DATOFRA], [DATOTIL], [NYKID], [UKE], [CMX_DATOIMPORTERT], [AAR], [DATAAREAID], [IMPORTERT]) 
SELECT [Anleggsid],[Volum], [FraDato], [TilDato], [Axaptakid], [Uke],  [CMX_DatoImportert], [Aar],[DataAereaId], [Importert] FROM [SourceTable] where status=0

SET @errorcode=@@ERROR
IF @errorcode<>0 BEGIN
    RAISERROR('Error. Rolling back..',16,10)
    IF @@TRANCOUNT<>0 ROLLBACK

    SET XACT_ABORT OFF
    RETURN(@errorcode)
END

--Oppdater status
Update SourceTable set status=1 where status=0 
SET @errorcode=@@ERROR
IF @errorcode<>0 BEGIN
    RAISERROR('Error. Rolling back..',16,10)
    IF @@TRANCOUNT<>0 ROLLBACK

    SET XACT_ABORT OFF
    RETURN(@errorcode)
END
COMMIT TRAN

SET XACT_ABORT OFF





Similar Threads
Thread Thread Starter Forum Replies Last Post
process.startinfo opens new instance of process Anypond General .NET 0 August 28th, 2008 05:35 AM
Report Viewer is hanging up rachel_caleb13 Crystal Reports 0 July 11th, 2007 05:28 AM
VS2003 hanging gbrown VS.NET 2002/2003 3 October 9th, 2006 01:50 PM
code downloads - hanging! daboooooh BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 May 14th, 2006 09:50 AM
page hanging Adam H-W Javascript 6 October 28th, 2004 07:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.