Edit

Lesson 3: Drop the conversation objects

Applies to: SQL Server Azure SQL Managed Instance

In this lesson, you learn to drop the objects that enabled a database to support a conversation in the database.

Procedures

Note

The code samples in this article were tested using the AdventureWorks2025 sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page.

Switch to the AdventureWorks2008R2 database

  • Copy and paste the following code into a Query Editor window, then run it to switch context to the AdventureWorks2008R2 database.

    USE AdventureWorks2008R2;
    GO
    

Drop the conversation objects

  • Copy and paste the following code into a Query Editor window, then run it to drop the objects that were used to support the conversation.

    IF EXISTS (SELECT *
               FROM sys.services
               WHERE name = N'//AWDB/1DBSample/TargetService')
        DROP SERVICE [//AWDB/1DBSample/TargetService];
    
    IF EXISTS (SELECT *
               FROM sys.service_queues
               WHERE name = N'TargetQueue1DB')
        DROP QUEUE TargetQueue1DB;
    -- Drop the initiator queue and service if they already exist.
    
    IF EXISTS (SELECT *
               FROM sys.services
               WHERE name = N'//AWDB/1DBSample/InitiatorService')
        DROP SERVICE [//AWDB/1DBSample/InitiatorService];
    
    IF EXISTS (SELECT *
               FROM sys.service_queues
               WHERE name = N'InitiatorQueue1DB')
        DROP QUEUE InitiatorQueue1DB;
    
    IF EXISTS (SELECT *
               FROM sys.service_contracts
               WHERE name = N'//AWDB/1DBSample/SampleContract')
        DROP CONTRACT [//AWDB/1DBSample/SampleContract];
    
    IF EXISTS (SELECT *
               FROM sys.service_message_types
               WHERE name = N'//AWDB/1DBSample/RequestMessage')
        DROP MESSAGE TYPE [//AWDB/1DBSample/RequestMessage];
    
    IF EXISTS (SELECT *
               FROM sys.service_message_types
               WHERE name = N'//AWDB/1DBSample/ReplyMessage')
        DROP MESSAGE TYPE [//AWDB/1DBSample/ReplyMessage];
    GO