Hi all,
I started working at a new company and have discovered the pervasive usage of "Select 1 from.." in their stored procedures. Why? It just returns 1. Here's one use:
==============================================
if exists (select 1 from dbo.sysobjects a join sysindexes b ON a.id = b.id
where a.name = 'DIM_CUSTOMER' AND b.name = 'IX_DIM_CUSTOMER_TYPE')
drop index dbo.DIM_CUSTOMER.IX_DIM_CUSTOMER_TYPE
================================================
If the objects exist, then Select 1 will never be untrue or true (it's not boolean) because select 1 returns a 1. I don't get it.
Thanks
--Bill
--Bill
One may not reach the dawn save by the path of the night
--Kahlil Gibran
I started working at a new company and have discovered the pervasive usage of "Select 1 from.." in their stored procedures. Why? It just returns 1. Here's one use:
==============================================
if exists (select 1 from dbo.sysobjects a join sysindexes b ON a.id = b.id
where a.name = 'DIM_CUSTOMER' AND b.name = 'IX_DIM_CUSTOMER_TYPE')
drop index dbo.DIM_CUSTOMER.IX_DIM_CUSTOMER_TYPE
================================================
If the objects exist, then Select 1 will never be untrue or true (it's not boolean) because select 1 returns a 1. I don't get it.
Thanks
--Bill
--Bill
One may not reach the dawn save by the path of the night
--Kahlil Gibran