Wednesday, December 6, 2017

SQL SERVER - How drop table (with table exists check)

This example shows script for drop table with check if this table exists in DB.
use db;

set nocount on;

if exists( select 'x' from information_schema.tables 
           where
           lower( table_name ) = 'sql_detail_methods'            
         )
begin
  drop table [sql_detail_methods];
end;

No comments:

Post a Comment