I am working with an Arcgis Enterprise SDE Database in SQL Server.
I am attempting to use a SQL update query to update a new field for many of the records in the database. This field is populated from a table that is created in other processing steps. In the query I update Table Views, which can then be QA/QC’d before being integrating into the database.
(see below for code)
When I test the query in SSMS, for all the datasets I want to update, it works with no errors. The issue is that when I attempt to run the same query via a batch file in command line it hangs indefinitely (16+ hours with no response). It does not even output messages to suggest it has started processing. I have no idea if it is a specific table that is causing the problem, or if it is throwing some kind of error.
My major confusion is that it only hangs when I run the test for all of the datasets. If I run the query for a small subset of the tables (1 or 2) it works in both SSMS and in Command Line and prints outputs to command line as intended.
My DBA insists that my query will not work, even though it works without error in SSMS. She says I must use a cursor to do this. However she has yet to give any kind of explanation as to why she believes this. Thus I am asking the community.
My main question is, what is happening here? Or, if this is not enough information, how can I potentially debug this to identify and fix the issue?
SQL QUERY:
SET NOCOUNT ON EXEC dbase.sde.set_current_version "VERSION.TEST"; EXEC dbase.sde.edit_version "VERSION.TEST", 1; BEGIN TRY BEGIN TRAN; RAISERROR ('B processing begun', 10,1) WITH NOWAIT UPDATE BV SET BV.MA = ( SELECT BJ.MC FROM BJ WHERE BJ.Key = BV.Key AND BJ.MA <> BJ.MC ) WHERE EXISTS ( SELECT 1 FROM BJ WHERE BJ.Key = BV.Key AND BJ.MA <> BJ.MC ); -- Repeat above for each desired dataset starting with RAISEERROR RAISERROR ('All Processing Complete, Commiting Transaction.', 10,1) WITH NOWAIT COMMIT; EXEC devsde.sde.edit_version "SYOKLIC1.TEST", 2; END TRY BEGIN CATCH COMMIT; EXEC dbase.sde.edit_version "VERSION.TEST", 2; PRINT '*************Error Detail****************'; PRINT 'Error Number :' + CAST(ERROR_NUMBER() AS VARCHAR); PRINT 'Error Severity:' + CAST(ERROR_SEVERITY() AS VARCHAR); PRINT 'Error State :' + CAST(ERROR_STATE() AS VARCHAR); PRINT 'Error Line :' + CAST(ERROR_LINE() AS VARCHAR); PRINT 'Error Message :' + ERROR_MESSAGE(); END CATCH
BATCH FILE:
@echo on python preprocessing.py sqlcmd -U username -P password -S server\dbase -i myquery.sql python postprocessing.py pause