Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created January 17, 2018 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpoDesign/17fb8e291863d10e4d42790d8659385e to your computer and use it in GitHub Desktop.
Save cpoDesign/17fb8e291863d10e4d42790d8659385e to your computer and use it in GitHub Desktop.
Old way of checking if item exists before drop
IF EXISTS(SELECT 1 FROM sys.objects AS O WHERE O.name = 'Product' AND O.[type] = 'U')
BEGIN
    DROP TABLE [SomeTable]
END
 
IF OBJECT_ID('dbo.Product', 'U') IS NOT NULL
BEGIN
DROP TABLE dbo.Product;
END
IF EXISTS (SELECT * FROM sys.triggers WHERE name = 'trProductInsert')
BEGIN
DROP TRIGGER trProductInsert
END
 
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment