October 3, 2014 at 9:10 pm
stephen.long.1 (10/3/2014)
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. 🙂
It is when the "customer" is tied to the chair, the pork chops are frozen, and the method of delivery is a 3 banded "Wrist Rocket" slingshot fired at point blank range. 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
October 3, 2014 at 9:12 pm
Steve Jones - SSC Editor (10/3/2014)
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.
Heh... I forgot to say that it's a great question but just had to add the "D" option (stands for [font="Arial Black"]D[/font]epression left in the forehead by high velocity pork). 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
October 6, 2014 at 12:26 am
Nice trivia question, thanks Steve.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 6, 2014 at 12:26 am
Hugo Kornelis (10/3/2014)
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.
I can only imagine this being useful while testing scripts and you're too lazy to put TOP everywhere 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 6, 2014 at 10:20 am
Thanks for the question.
October 6, 2014 at 10:20 am
I've never had a need to use this by the way.
October 9, 2014 at 3:32 am
Ed Wagner (10/3/2014)
I learned something today, so thank you.
Yes, Thank u Steve.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
October 9, 2014 at 3:35 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.
Same here 🙂
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
Viewing 8 posts - 16 through 22 (of 22 total)
You must be logged in to reply to this topic. Login to reply