October 2, 2014 at 8:41 pm
Comments posted to this topic are about the item Row limits
October 3, 2014 at 12:50 am
Thank you for the post, Steve, good one.
Happy weekend!!!
(To all Indians out there - Happy Dussehra)
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
October 3, 2014 at 3:11 am
Thank you Steve. It's always nice when my educated guess matches the documentation!
October 3, 2014 at 5:09 am
I learned something today, so thank you.
October 3, 2014 at 5:57 am
Thanks for the question.
I'm on a roll lately! π
But I must say that I do not use this feature in my coding.
---------------
Mel. π
October 3, 2014 at 6:13 am
SqlMel (10/3/2014)
But I must say that I do not use this feature in my coding.
I haven't either. I'd use TOP myself, but this is another nice tool to have in the toolbox if you ever need it.
October 3, 2014 at 6:32 am
I haven't known that ROWCOUNT will override TOP, but I kind of guessed.
When I tried it, I've noticed that ROWCOUNT locks number of results for the session, so if you run TOP <whatever> later in the same session, it still will be 2, so be mindful.
October 3, 2014 at 7:19 am
Ed Wagner (10/3/2014)
SqlMel (10/3/2014)
But I must say that I do not use this feature in my coding.I haven't either. I'd use TOP myself, but this is another nice tool to have in the toolbox if you ever need it.
+1 Thanks for the question Steve
October 3, 2014 at 7:43 am
Ed Wagner (10/3/2014)
SqlMel (10/3/2014)
But I must say that I do not use this feature in my coding.I haven't either. I'd use TOP myself, but this is another nice tool to have in the toolbox if you ever need it.
Keep in mind that SET ROWCOUNT is deprecated for INSERT/UPDATE/DELETE and will be removed in future versions of SQL Server
/HΓ₯kan Winther
MCITP:Database Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
MCSE: Data Platform
October 3, 2014 at 7:43 am
Heh... the correct answer isn't actually listed. Answer "D" should be "During the mandatory peer review, you get a trip to the woodshed for a porkchop dinner for writing such junk code". π
--Jeff Moden
Change is inevitable... Change for the better is not.
October 3, 2014 at 9:09 am
Ed Wagner (10/3/2014)
SqlMel (10/3/2014)
But I must say that I do not use this feature in my coding.I haven't either. I'd use TOP myself, but this is another nice tool to have in the toolbox if you ever need it.
This used to come in handy before TOP supported variables.
October 3, 2014 at 9:13 am
Steve, thanks for the easy question to end the week. I prefer TOP for my queries because its effects don't persist, but several of my peers use SET ROWCOUNT.
Jeff, your comment made me laugh :laugh: (thanks), and I agree with you, but I don't think a pork chop dinner should be considered punishment. π
October 3, 2014 at 9:16 am
Jeff Moden (10/3/2014)
Heh... the correct answer isn't actually listed. Answer "D" should be "During the mandatory peer review, you get a trip to the woodshed for a porkchop dinner for writing such junk code". π
LOL, perhaps, but imagine
create proc spReallyBusyProc
@someparam int
as
begin
set no count on
set rowcount @someparam
-- do 40 things, because that's how we write procs
select top (@y_less_than_@someparam)
somecol
from sometable
-- do 10 more things
end
It seems like it might be tricky, but it makes sense.
Set rowcount 4 - we return 4 rows
select top 8 - we return 8 rows from the query, but only 4 get displayed because of the above.
October 3, 2014 at 12:06 pm
Interesting...I have never used SET ROWCOUNT or seen it used anywhere before. G.I. JOE!!
Aigle de Guerre!
October 3, 2014 at 3:01 pm
Meow Now (10/3/2014)
Interesting...I have never used SET ROWCOUNT or seen it used anywhere before. G.I. JOE!!
That's actually a good thing; please don't get into the habit of using it now.
It is already deprecated for INSERT, UPDATE, DELETE. I don't know if it ever supported MERGE. And I can only hope that it will soon be deprecated for SELECT.
You do not want to know how many seasoned professionals did unspeakable things to their data due to setting SET ROWCOUNT and then forgetting to reset it.
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply