if exists (select 1 from sysobjects where xtype = 'u' and id = object_id('temp..#tb')) drop table #tb go
drop table tb --直接删除表delete from tb --删除表所有数据,有日志truncate table tb --删除表所有数据,没有日志
Create table #tb (id int, name nvarchar(20)) GO--1-- if object_id('#tb') is null drop table #tb GO --2-- if not exists (select 1 from sysobjects where xtype = 'u' and id = object_id('temp..#tb')) drop table #tb GO--1-- 不加not null才可以删除 (判断是否存在表不是not null吗?) --2--要加not exists 才可以删除 ,不合逻辑我SQL2005有问题吗
if object_id('#tb') is null drop table #tb 条件是如果#tb表是空,也就是不存在,你删个屁啊
if exists (select 1 from sysobjects where xtype = 'u' and id = object_id('temp..#tb'))
drop table #tb
go
Create table #tb
(id int,
name nvarchar(20))
GO--1--
if object_id('#tb') is null
drop table #tb
GO
--2--
if not exists (select 1 from sysobjects where xtype = 'u' and id = object_id('temp..#tb'))
drop table #tb
GO--1-- 不加not null才可以删除 (判断是否存在表不是not null吗?)
--2--要加not exists 才可以删除 ,不合逻辑我SQL2005有问题吗
drop table #tb
条件是如果#tb表是空,也就是不存在,你删个屁啊