Number of rows affected after update of MSSQL table using ROWCOUNT

We 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
rs.open "select @@rowcount ", conn
dt=rs(0).value
Response.Write " Nos of records affected : " & dt

The above command will display total number of records changed because of the update command.

Be the first to post comment on this article :





Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer