c# - SQL Server Global Temp Table Still Exist After Drop -
i'm trying run query in sql server. inside query there part this:
... if exists(select * tempdb.dbo.sysobjects id = object_id(n'tempdb.dbo.[##emp]')) drop table ##emp select * ##emp #emp (nolock) ...
the thing keep getting error says ##emp
exists. how thing possible when checked if exist drop
? tried remove if exist
part , manually drop table, still says table exists.
check both temp table statuses simple:
select * tempdb..sysobjects name '%emp%'
then shure handle deletion , recreation both:
begin transaction ... if exists(select * tempdb..sysobjects id = object_id(n'tempdb..[#emp]')) drop table #emp create table #emp(exampleid uniqueidentifier); ... if exists(select * tempdb.dbo.sysobjects id = object_id(n'tempdb.dbo.[##emp]')) drop table ##emp select * ##emp #emp ... commit transaction
as @damien-the-unbeliever pointed out globally visible temporary table can quite troublesome, double check if need it.
in case it's confusing have such similar names...
Comments
Post a Comment