Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you count Rows Affected in an Update Statement?

Status
Not open for further replies.

litsz02

Technical User
Aug 26, 2004
45
US
I have a table(AccountLookup) with a list of accounts that need to update another table(AccountDetail) with a new account number. BUT Not every record in the AccountLookup table has a match.

I need to find a way to count Match/Unmatched accounts.

The way I am updating is just a simple update statement, via a cursor(pointer).

i.e.
While....
Set Cursor = Accountlookup.Account
Update AccountDetail where Account = Accountnumber
Move Cursor
Loop

Can anyone point me in the right direction? Thanks for your help!
 
@@ROWCOUNT gives information you need (rows affected by the last statement).

There is probably no need for cursor (baaad, lame, slow, blah) but that's another story. Or maybe isn't?
 
Sure wish we had a FAQ to refer him to. [bigsmile]
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
That's exactly what I was looking for. I can't believe i missed that. Thanks so much everyone..Very speedy responses helped alot!

Thanks again!!
 
BTW never perfom an update using a cursor. This is very inefficent.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top