-- determine if the database exists
IF EXISTS (SELECT * from MASTER.sys.sysdatabases WHERE name = ' library name ')
PRINT ' exists '
Else
PRINT ' NOT EXISTS '
-- determine if the name of the table to be created exists
IF EXISTS (Select * from sysObjects Where name = ' table name ' and Type in (' S ', ' U '))
PRINT ' exists '
ELSE
PRINT ' NOT EXISTS '
GO
-- determine if you want to create a temporary table exists
If object_id (' tempdb.dbo. #Test ') is a temporary table name #Test not null--
Begin
print ' exists '
End
Else
Begin
print ' does not exist '
End
-- determine if the stored procedure name to be created exists
IF EXISTS (Select * from sysObjects Where name = ' stored procedure name ' and Type in (' S ', ' P '))
PRINT ' exists '
ELSE
PRINT ' NOT EXISTS '
GO
-- Determine if the column name exists
IF EXISTS (SELECT o.name as table name , c.name as column name from SYSOBJECTS O INNER JOIN syscolumns C on O.id=c . ID WHERE o.name= ' table name ' and c.name = ' column name ')
SELECT ' EXISTS '
ELSE
SELECT ' Not EXISTS '
--whether the table A column C exists
IF not EXISTS (SELECT 1 from SYSOBJECTS T1 INNER joins syscolumns T2 on t1.id=t2.id WHERE t1.name= ' A ' and t2.name= ' C ')
-- a function to judge the existence of a table name
IF col_length (' table name ', ' column name ' ) is NULL
PRINT ' NOT EXISTS '
ELSE
PRINT ' exists '
--New Modified view sp use first DROP,&NBSP, create .  Span style= "font-family: the song Body;" If you have * view using Span style= "Font-family:times New Roman;" >sp_refreshview refresh exec
if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Rpt_2033300001_v] ') and OBJECTPROPERTY (ID, N ' isview ') = 1)
Drop view [dbo]. [Rpt_2033300001_v]
GO
CREATE VIEW Dbo.rpt_2033300001_v
As
*********
if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Stored Procedure name ] ') and OBJECTPROPERTY (ID, N ' isprocedure ') = 1)
-- Delete stored procedures
drop procedure [dbo]. [ stored procedure name ]
GO
SQL to determine if "library, table, column, view, stored procedure" exists