Phil Parkin wrote:
MVDBA (Mike Vessey) wrote:
I hate "where 1=0" - I ..use "where @debugmode=1" and pass that in as a parameter. the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying
WHERE 1 = 0 is not always a debugging construct. Eg. SELECT ... INTO #SomeTable WHERE 1 = 0 Creates an empty temp table with the desired structure (as defined in the SELECT).
have you ever tried to get an estimated execution plan for performance tuning with a "select into" in the proc? the optimiser just throws an error about invalid object #sometable
It's on our coding standards list as "annoys the DBA when he has to improve performance" 🙂
right above "forgetting to remove your debug code will exclude you from the free cakes the DBA makes for you"
all of our guys have the redgate tools, if you write a "Select * into", hover over it, then it will allow you to generate a CREATE #Table script and convert it into
create table #x
insert into x select * from ....
one of the most useful features of toolbelt i have used in the past week