PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 0ms

/SqlServer2005_SP2/HelloWorld/Scripts/HelloWorld/Cleanup.sql

#
SQL | 83 lines | 46 code | 13 blank | 24 comment | 0 complexity | 8583f2c2518838424317f1846421acd5 MD5 | raw file
 1--------------------------------------------------------------------
 2-- Summary: Cleanup script for Service Broker HelloWorld sample.
 3-- 
 4--------------------------------------------------------------------
 5-- This file is part of the Microsoft SQL Server Code Samples.
 6-- Copyright (C) Microsoft Corporation. All Rights reserved.
 7-- This source code is intended only as a supplement to Microsoft
 8-- Development Tools and/or on-line documentation. See these other
 9-- materials for detailed information regarding Microsoft code samples.
10--
11-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF
12-- ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14-- PARTICULAR PURPOSE.
15--------------------------------------------------------------------
16-- Drop InitiatorService if the service exists.
17
18IF EXISTS (SELECT *
19           FROM sys.services
20           WHERE name = 'InitiatorService')
21BEGIN
22    DROP SERVICE InitiatorService ;
23END ;
24GO
25
26-- Drop TargetService if the service exists.
27
28IF EXISTS (SELECT *
29           FROM sys.services
30           WHERE name = 'TargetService')
31BEGIN
32    DROP SERVICE TargetService ;
33END ;
34GO
35
36-- Because contracts depend on message types, the script
37-- drops contracts before dropping message types.
38
39-- Drop HelloWorldContract if the contract exists.
40
41IF EXISTS (SELECT *
42           FROM sys.service_contracts
43           WHERE name = 'HelloWorldContract')
44BEGIN
45    DROP CONTRACT HelloWorldContract ;
46END ;
47GO
48
49-- Drop HelloWorldMessage if the message type exists.
50
51IF EXISTS (SELECT *
52           FROM sys.service_message_types
53           WHERE name = 'HelloWorldMessage')
54BEGIN
55    DROP MESSAGE TYPE HelloWorldMessage ;
56END ;
57GO
58
59
60-- Drop InitiatorQueue if the queue exists.
61
62IF OBJECT_ID('[dbo].[InitiatorQueue]') IS NOT NULL AND
63   EXISTS(SELECT *
64          FROM sys.objects
65          WHERE object_id = OBJECT_ID('[dbo].[InitiatorQueue]')
66            AND type = 'SQ')
67BEGIN
68    DROP QUEUE [dbo].[InitiatorQueue] ;
69END ;
70GO
71
72-- Drop TargetQueue if the queue exists.
73
74IF OBJECT_ID('[dbo].[TargetQueue]') IS NOT NULL AND
75   EXISTS(SELECT *
76          FROM sys.objects
77          WHERE object_id = OBJECT_ID('[dbo].[TargetQueue]')
78            AND type = 'SQ')
79BEGIN
80    DROP QUEUE [dbo].[TargetQueue] ;
81END ;
82GO
83--------------------------------------------------------------------