Results 1 to 5 of 5

Thread: if exists DROP PROCEDURE/VIEW

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    if exists DROP PROCEDURE/VIEW

    how can I drop a propcedure or a view without error for MS SQL 2000/2500

    for a table

    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[myTABLE]') AND type in (N'U'))
    DROP TABLE [dbo].[myTABLE]


    and for a procedure

    IF EXISTS ???
    DROP PROCEDURE [dbo].[SP_myTABLE_Count]


    thank you for helping

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SP_myTABLE_Count]') AND type in (N'P'))
    DROP PROCEDURE [dbo].[SP_myTABLE_Count]

  3. #3
    Join Date
    Apr 2006
    Posts
    178
    thank you skhanal

    for a view is it ?

    AND type in (N'V'))
    Last edited by anselme; 05-20-2007 at 10:41 AM.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Yes, you got it.

  5. #5
    Join Date
    Apr 2006
    Posts
    178
    thanks rmia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •