Determines whether a table (temporary table) exists and whether a stored procedure exists.
1. Determine whether a formal table or stored procedure has a select * from dbo. sysobjects where id = OBJECT_ID (N 'dbo. users') and type = 'U' -- U table
Select * from dbo. sysobjects where id = object_id (N 'usp _ insertalipayfeedback') and type = 'P' -- P indicates the Stored Procedure
2. Determine the temporary table type select * from tempdb. dbo. sysobjects where id = OBJECT_ID (N 'tempdb. dbo. # tempa ') and type = 'U' -- U table
Select * from tempdb. dbo. sysobjects where id = OBJECT_ID (N 'usp _ insertalipayfeedback') and type = 'P' -- P indicates the Stored Procedure
Object type. It can be one of the following values:
C = CHECK constraint D = DEFAULT value or DEFAULT constraint F = foreign key constraint
FN = scalar function IF = nested table function K = primary key or UNIQUE constraint
L = log P = Stored Procedure R = rule RF = copy and filter Stored Procedure
S = system table TF = table function TR = trigger U = User table V = view X = Extended Stored Procedure
For example, if exists (select * from tempdb. dbo. sysobjects where id = OBJECT_ID (n' tempdb. dbo. # tempa ') -- whether the temporary table drop table # tempa exists -- delete create table # tempa (Num int, Name varchar (20) default 'name' -- column default value settings) declare @ a int set @ a = 1 while @ a <30 begin insert into # tempa (Num) values (@) set @ a = @ a + 1 endselect * from # tempa