Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Object already exist
Message
 
 
À
02/09/2007 13:22:00
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01251908
Message ID:
01251912
Vues:
15
You cannot have statements that create the same temp table more than once even if only one of them will be executed based on conditions. You have to redisign your code so there's only one such statement. Something like
  SELECT * INTO #mytable FROM inserted WHERE 1=2
  IF condition = 'A'
    INSERT INTO #mytable  SELECT * FROM inserted
  ELSE
    INSERT INTO #mytable SELECT * FROM inserted WHERE abc = 'A'
>I have trigger code as below. SQL Server complaint "There is already an object named "#mytable" in the database. But I already restart the server.
>
>
CREATE PROCE myTrigger ON mytable FOR INSERT
>AS
>BEGIN
>  IF condition = 'A'
>    SELECT * INTO #mytable FROM inserted
>  ELSE
>    SELECT * INTO #mytable FROM inserted WHERE abc = 'A'
>END
>
>If I renamed one of them, the error will be gone.
>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform