Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How many rows were affected?
Message
 
À
07/12/2005 16:01:43
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01075860
Message ID:
01075926
Vues:
26
OK using your tip from your message I have the following code (simplified a lot since I don't want to post my 42 nested updates<s>):
BEGIN TRANSACTION

UPDATE mytable
SET Name = @Name1
WHERE Id = @Id1

IF @@ROWCOUNT = 1
  BEGIN
  UPDATE mytable
  SET Name = @Name2
  WHERE Id = @Id2
  
  IF @@ROWCOUNT = 1
    BEGIN
    UPDATE mytable
    SET Name = @Name3
    WHERE Id = @Id3
    
    IF @@ROWCOUNT = 1
      BEGIN
      COMMIT TRANSACTION
      END
    ELSE
      BEGIN
      ROLLBACK TRANSACTION
      END
    END
  ELSE
    BEGIN
    ROLLBACK TRANSACTION
    END
  END
ELSE
  BEGIN
  ROLLBACK TRANSACTION
  END
Lets say there is a match for @Id1 and @Id2 but there is no match for @Id3, everything seem to rollback just fine but my application tells me that 2 rows were affected.
Is there a way to, when ROLLBACK is issued, to return 0 rows affected to the client?

Einar
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform