---
title: "How to get @@error and @@rowcount at the same time?"  
description: "How to get @@error and @@rowcount at the same time?"  
author: "Anonymous User"  
published: 2011-05-11  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/873/how-to-get-error-and-rowcount-at-the-same-time  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# How to get @@error and @@rowcount at the same time?

If @@Rowcount is checked after Error checking statement then it will have 0 as the value of @@Recordcount as it would have been reset.\
And if @@Recordcount is checked before the error-checking statement then @@Error would get reset. To get @@error and @@rowcount at the same time do both in same statement and store them in local variable. SELECT @RC = @@ROWCOUNT, @ER = @@ERROR

## Answers

### Answer by Anonymous User

If @@Rowcount is checked after Error checking statement then it will have 0 as the value of @@Recordcount as it would have been reset.\
And if @@Recordcount is checked before the error-checking statement then @@Error would get reset. To get @@error and @@rowcount at the same time do both in same statement and store them in local variable. SELECT @RC = @@ROWCOUNT, @ER = @@ERROR


---

Original Source: https://www.mindstick.com/interview/873/how-to-get-error-and-rowcount-at-the-same-time

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
