I am inserting a number or rows into a table using INSERT with SELECT. After the transaction, I want to store both the @@ROWCOUNT and @@ERROR values into locallay declared variables.
INSERT SubscriberList (PublicationId, SubscriberId)
SELECT @PublicationId, S.SubscriberId
FROM Subscribers S
SET @NoRows = @@ROWCOUNT
SET @ErrorCode = @@ERROR
I wasn't sure if this was valid in as much if I call one, will I negate the other?
Set them both at once:
SELECT @NoRows = @@ROWCOUNT, @ErrorCode = @@ERROR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With