SQL query skills two ways to query whether a table exists
Method 1: Determine whether a system object exists
Declare
@ Dbtablefilename varchar (100)
Set @ dbtablefilename = 'tx'
If objectproperty (object_id (@ dbtablefilename), 'isusertable') is not null
Print 'exists'
Else
Print 'not exists'
If object_id (@ dbtablefilename) is not null
Print 'exists'
Else
Print 'not exists'
If exists (select object_id (@ dbtablefilename ))
Print 'exists'
Else
Print 'not exists'
Method 2 query a table
Declare
@ Dbtablefilename varchar (100)
Set @ dbtablefilename = 'tx'
If exists (select 1
From sysobjects
Where name = @ dbtablefilename
And type = 'U ')
Print 'exists'
Else
Print 'not exists'
Organized from http://community.csdn.net/Expert/topic/5283/5283952.xml? Temp =. 733227.
Thank you.Loomman (yijian)Xiequanqin (New day, new start point !) Marco08) Bugchen888 (Bug) Caixia615 (* ^_^ *) then my neighbors R !. The hacker misses your ghost. (* ^_^ *)