Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function To Test For Table Doesn't Work
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01328338
Message ID:
01328380
Vues:
10
--drop table #temp

create table #temp (ch char(1))


--if object_Id(@tablename) is not null
declare @tablename varchar(10)
declare @execS nvarchar(max)
set @tablename = '#temp' 

if object_id('tempdb..#temp') is not null
  begin
  print 'Try to delete'
  set @execS = 'drop table ' + @tablename
  exec sp_executesql @execS
end
This works.

And this
create table #temp (ch char(1))


--if object_Id(@tablename) is not null
declare @tablename varchar(10)
declare @execS nvarchar(max)
set @tablename = 'tempdb..#temp'

if object_id(@tablename) is not null
  begin
  print 'Try to delete'
  set @execS = 'drop table ' + @tablename
  exec sp_executesql @execS
end
doesn't.

I don't know what's going on. Looks like it could not detect immediatelly using the name as a variable.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform