TSQL delete table if it already exists


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. IF EXISTS (
  2. SELECT 1 FROM INFORMATION_SCHEMA.TABLES
  3. WHERE TABLE_NAME = 'MyTable' AND TABLE_SCHEMA = 'dbo'
  4. )
  5. BEGIN
  6. DROP TABLE dbo.MyTable
  7. PRINT 'Dropped dbo.MyTable'
  8. END

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.