626
Views
5
Comments
Solved
Getting total affected rows in advanced "UPDATE" query
Question

Good morning!

Here's the doubt. I'll be having a timer to update 100 000 rows each run. I want to rerun the timer if the ammount of rows update is equal to 100 000. 

The probability of having more rows when I update exactly 100 000 rows in a select top 100 000 (subquery filter), is very, very high. So instead of running another query just like the subquery filter to know if count or length is > 100 000, I would like to use the info that sql server management studio gives you "100 000 rows affeted". Is this available in anyway... or... I'll need to make that query to know that?

Thanks in advance.

Regards

2019-05-22 11-30-09
Marcelo Ferreira
Solution

Hi,

You can do a RowCount after the update query. Look at this example:

Any question let me know.

Regards,

Marcelo

2019-01-30 15-15-25
Gilfoyle

That "query" on the input parameters will count the rows the previous query affected?

Thanks. Will test in a couple of hours.

Regards

2019-05-22 11-30-09
Marcelo Ferreira

Hi,

In T-SQL ti will work. For MySql you can use ROW_COUNT(). for Oracle sql%rowcount. BUt I only test this on T-SQL.

Regards,

Marcelo

2019-01-30 15-15-25
Gilfoyle

IT... Works!


Thanks!

2018-07-06 11-13-55
Nathan Hobbs

NOTE: For this to work, you MUST set "Expand Inline" to TRUE.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.