Is there a difference in performance between TOP and SET ROWCOUNT or do they just get executed in the same manner?
Is there a difference in performance between TOP and SET ROWCOUNT or do they
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, functionally they are the same thing. As far as I know there are no significant performance differences between the two.
Just one thing to note is that once you have
set rowcountthis will persist for the life of the connection so make sure you reset it to0once you are done with it.EDIT (post Martin’s comment)
The scope of
SET ROWCOUNTis for the current procedure only. This includes procedures called by the current procedure. It also includes dynamic SQL executed viaEXECorSP_EXECUTESQLsince they are considered ‘child’ scopes.Notice that
SET ROWCOUNTis in aBEGIN/ENDscope, but it extends beyond that.Result = 100 rows, then 102 rows