I am getting an error when trying to execute SQL Server system procedures such as sp_addLinkedServer and sp_dropserver etc from python script

      USE [master]

      EXEC master.dbo.sp_dropserver @server=N'DS', @droplogins='bs'

Error :

          (15002, b"The procedure 'sys.sp_dropserver' cannot be executed within a transaction.DB-Lib 
          error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL 

1 Answer 1


The error is quite clear - you can't run this SP in a transaction, Some libraries (ODBC etc) support implicit transactions (meaning every piece of SQL will be run in a transaction) so you need to dig into why these are enabled. Explained in the link below

or just add SET IMPLICIT_TRANSACTIONS OFF in the line before the SP call


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.