SQLServer 2016 Create and drop objects part1

/*Earlier sqlserver versions*/

IF OBJECT_ID(N’dbo.t1′, ‘U’) IS NOT NULL
DROP TABLE dbo.t1
IF OBJECT_ID(N’#temp’, ‘U’) IS NOT NULL
DROP TABLE #temp
IF OBJECT_ID(N’##tmp’, ‘U’) IS NOT NULL
DROP TABLE ##tmp
IF OBJECT_ID(N’dbo.vw1′, ‘V’) IS NOT NULL
DROP VIEW dbo.vw1
IF OBJECT_ID(N’dbo.proc1′, ‘P’) IS NOT NULL
DROP PROC dbo.proc1
USE master
GO
IF EXISTS (SELECT name FROM sys.databases WHERE name = N’test2′)
DROP DATABASE test2
GO

/*from Sqlserver 2016*/

DROP TABLE IF EXISTS #tmp
DROP TABLE IF EXISTS ##tmp
DROP VIEW IF EXISTS dbo.vw1
DROP PROCEDURE IF EXISTS dbo.proc1
DROP DATABASE IF EXISTS test2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s