C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
2
Reply
How the rowcount works?
sarika
18y
5.8k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
RowCount returns total number of rows affected by last statement execution , you can also preserve and reset rowcount anytime .
Manav Pandya
7y
1
Hi,
@@ROWCOUNT is a system variable which will return the no of rows affected in the DML operations.
The ROWCOUNT is one of the performance tuning mechanism. If you use the below query
what it does if you have n number of records then it has to be sorted then it will take the 5 records.
SELECT TOP 5 * FROM Employees ORDER BY Salary DESC
There is an alternative way to achieve the same result.
SET ROWCOUNT 5
SELECT * FROM Employees ORDER BY Salary DESC
SET ROWCOUNT 0
It wont list the entire record. It will get stop when the resultset reach 5 for the current single connection.
we have to set ROWCOUNT 0 for release the set count rows. Otherwise it will return the same 5 rows for that connection.
But i think there is some impact on DML operations. Yes, if you update the records then it may restrict.
Senthilkumar
16y
1
Message