PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Kilimanjaro_SR1/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. IF EXISTS (SELECT *
  18. FROM sys.services
  19. WHERE name = 'InitiatorService')
  20. BEGIN
  21. DROP SERVICE InitiatorService ;
  22. END ;
  23. GO
  24. -- Drop TargetService if the service exists.
  25. IF EXISTS (SELECT *
  26. FROM sys.services
  27. WHERE name = 'TargetService')
  28. BEGIN
  29. DROP SERVICE TargetService ;
  30. END ;
  31. GO
  32. -- Because contracts depend on message types, the script
  33. -- drops contracts before dropping message types.
  34. -- Drop HelloWorldContract if the contract exists.
  35. IF EXISTS (SELECT *
  36. FROM sys.service_contracts
  37. WHERE name = 'HelloWorldContract')
  38. BEGIN
  39. DROP CONTRACT HelloWorldContract ;
  40. END ;
  41. GO
  42. -- Drop HelloWorldMessage if the message type exists.
  43. IF EXISTS (SELECT *
  44. FROM sys.service_message_types
  45. WHERE name = 'HelloWorldMessage')
  46. BEGIN
  47. DROP MESSAGE TYPE HelloWorldMessage ;
  48. END ;
  49. GO
  50. -- Drop InitiatorQueue if the queue exists.
  51. IF OBJECT_ID('[dbo].[InitiatorQueue]') IS NOT NULL AND
  52. EXISTS(SELECT *
  53. FROM sys.objects
  54. WHERE object_id = OBJECT_ID('[dbo].[InitiatorQueue]')
  55. AND type = 'SQ')
  56. BEGIN
  57. DROP QUEUE [dbo].[InitiatorQueue] ;
  58. END ;
  59. GO
  60. -- Drop TargetQueue if the queue exists.
  61. IF OBJECT_ID('[dbo].[TargetQueue]') IS NOT NULL AND
  62. EXISTS(SELECT *
  63. FROM sys.objects
  64. WHERE object_id = OBJECT_ID('[dbo].[TargetQueue]')
  65. AND type = 'SQ')
  66. BEGIN
  67. DROP QUEUE [dbo].[TargetQueue] ;
  68. END ;
  69. GO
  70. --------------------------------------------------------------------