January 21, 2010 at 10:18 am
I have table Employees (Id,empid,empno,state)
Updating the table as
update Employees
SET empno=EmployeeNo
From Employees inner join OldEmp on empid=empid
where empno like 'CDW%'
From the above update I want to capture the following
1. no of recrods updated
2. state of the record which updated
3. Table Name where update ran
January 21, 2010 at 10:26 am
You can check the value of @@rowcount in order to know how many records got updated. The name of the table is just like the name of the table in your update statement (employee). As for the second question, I didn’t understand it.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 21, 2010 at 10:28 am
I just need to know how many recrods updted on which table and value from the coumn "state"
I want to insert them into a audit table (Tablename,RowsUpdated,State)
January 21, 2010 at 2:19 pm
You may find TSQL's Output Clause helpful. You can check BOL for details.
January 21, 2010 at 11:26 pm
This is one of the very few places where I'd condone the use of a Trigger. Read about triggers in Books Online.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply