1

When I want to drop a service which is already created, this error happens:

Msg 15151, Level 16, State 1, Line 316
Cannot drop the service '//Audit/Contract', because it does not exist or you do not have permission.

My sql query to perform drop operation is:

IF EXISTS(SELECT * FROM sys.service_contracts  WHERE NAME = '//Audit/Contract')
    DROP SERVICE [//Audit/Contract]

So, the main question is: What is the permissions necessary to drop a service in service-broker?

1

After I post this question, I just found my answer with some tricky way. I went to the left object explorer and delete the contract with it. but instead of submitting the form I click on the script button which produces the scripts. It was my mistake to drop a contract with drop service command. so the correct query to drop a contract is:

IF EXISTS(SELECT * FROM sys.service_contracts  WHERE NAME = '//Audit/Contract')
    DROP CONTRACT [//Audit/Contract]

I post this answer because maybe somebody encounter with this error and my guide can be useful to him/her.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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