Hi Guys,
DECLARE @cityID bigint;
set @cityID = NULL
--set @cityID = 3
SELECT ID,
Name,
CityID,
IsProvince
FROM TABLE t
WHERE ISNULL(t.CityID, -1) = ISNULL(@cityID, -1)
whenever the @cityID
is NULL
the t.CityID
is also NULL
for that record.
Only one record can ever be true for IsProvince
Is there a way to check without doing the if-else
clause if I want to do the following:
1) If the @cityID
is NULL
, then get the record whose IsProvince
is 1
2) If the @cityID
is NOT NULL
then get the record whose CityID = @cityID
Thanks,
Voodoo