Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many rows were affected?
Message
 
To
07/12/2005 16:01:43
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01075860
Message ID:
01075926
Views:
32
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform