Below you introduce SQL under the use of a variety of resources to determine the existence of the code, the need for friends can refer to, I hope you learn SQL functions and databases can be helpful. If the library exists if exists (SELECT * from Master.. sysdatabases where name=n ' library name ') print ' exists ' else print ' not EXISTS '-----------------determine if the table name to be created exists if exists (SELECT * From dbo.sysobjects WHERE id = object_id (N ' [D
Below you introduce SQL under the use of a variety of resources to determine the existence of the code, the need for friends can refer to, I hope you learn SQL functions and databases can be helpful. If the library exists if exists (SELECT * from Master.. sysdatabases where name=n ' library name ') print ' exists ' elseprint ' not EXISTS '-----------------determine if the table name to be created exists if exists (SELECT * FROM dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Table name] ') and OBJECTPROPERTY (ID, N ' isusertable ') = 1)--Delete tables drop table [dbo]. [Table name] GO-----------------determine if a temporary table exists if object_id (' tempdb.dbo. #Test ') is not nullbeginprint ' exists ' endelsebeginprint ' does not exist ' End-----------------Determine if the stored procedure name to be created exists if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Stored procedure name] ') and OBJECTPROPERTY (ID, N ' isprocedure ') = 1)--Delete Stored procedure drop procedure [dbo]. [Stored procedure name] GO-----------------Determine if the view name you want to create exists if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ View name] ') and OBJECTPROPERTY (ID, N ' isview ') = 1)--delete the View drop views [dbo]. [View name] GO-----------------determine if the function name to be created exists if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Function name] ') and xtype in (n ' FN ', n ' IF ', n ' TF ')--delete the function drop functions [dbo]. [function name]GOif col_length (' table name ', ' column name ') is Nullprint ' does not exist ' select 1 from sysobjects where ID in (select ID from syscolumns where name= ' Column name ') and name= ' table name ' article reprinted from the Webmaster Home: http://www.bitscn.com/pdb/mssql/201010/191258.html
Bo]. [table name] ') and OBJECTPROPERTY (ID, N ' isusertable ') = 1)--Delete table drop tables [dbo]. [Table name] GO-----------------determine if a temporary table exists if object_id (' tempdb.dbo. #Test ') is 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 dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Stored procedure name] ') and OBJECTPROPERTY (ID, N ' isprocedure ') = 1)--Delete Stored procedure drop procedure [dbo]. [Stored procedure name] GO-----------------determine if the view name you want to create exists if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ View name] ') and OBJECTPROPERTY (ID, N ' isview ') = 1)--delete the View drop views [dbo]. [View name] GO-----------------determine if the function name to be created exists if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Function name] ') and xtype in (n ' FN ', n ' IF ', n ' TF ')--delete the function drop functions [dbo]. [function name] GO if col_length (' Table name ', ' column name ') is a null print ' does not exist ' select 1 from sysobjects where ID in (select ID from syscolumns where nam E= ' column name ') and name= ' table name ' article reprinted from the Webmaster Home: http://www.bitscn.com/pdb/mssql/201010/191258.html
QL methods for determining the existence of function stored procedures