Number of rows affected after update of MSSQL table using ROWCOUNTWe can use any UPDATE , insert or delete command to change the records of a MSSQL table. After successful execution of the query we can find out how many rows or records got change or affected by the command. This is a confirmation of change in records. For example if a member is updating his or her password then we can expect the number of records got updated is equal to 1 . So after checking this we can display a confirmation message to the member.
Let us try with one simple example where we have changed all the passwords to the default value test. This will affect all the records of the table as we have not used any WHERE clause or any other condition. After the update command we will use one more query to get the number of rows changed. Here is the sample code.
We have assumed all the connection and record objects are already created. Here is the example.
rs.open "update member set password ='test1' where password ='test'", conn
The above command will display total number of records changed because of the update command.