MS SQL Server:

临时表要用下面的方法判断
create table #test(name char(8))
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#test') and type='U')
  print '#test exists'

用户表和系统表可以表下面的方法判断。
IF OBJECTPROPERTY ( object_id('authors'),'ISTABLE') = 1
  print 'Authors is a table'

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[detail]') and OBJECTPROPERTY(id, N'IsTable') = 1)
  print 'table [dbo].[detail] esist'

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[detail]') and (type='U' or type='S'))
  print 'table [dbo].[detail] esist'

相关文章:

  • 2022-02-15
  • 2021-06-19
  • 2021-10-30
  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
猜你喜欢
  • 2022-01-16
  • 2021-12-18
  • 2021-12-25
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
相关资源
相似解决方案