hi there,
Can anyone tell what wrong is with sp
My logic is if @house_type is not null check second cond
@facade. if it is not null do part1 else do part2.
it does work if the @house_type is not null and @facade is not null .At the moment if @house_type is null it goes to part2
Thank you
CREATE PROCEDURE hpg_spGetSiteInstr
(
@house_type int ,
@facade int
)
AS
IF @house_type IS NOT NULL
IF @facade IS NOT NULL
begin (part1)
SELECT * FROM tbl
WHERE tbl.house_type_id = @house_type
and tbl.facade_id = @facade
end
ELSE
begin (part2)
SELECT *
FROM tbl
WHERE tbl.house_type_id = @house_type
END
GO
Can anyone tell what wrong is with sp
My logic is if @house_type is not null check second cond
@facade. if it is not null do part1 else do part2.
it does work if the @house_type is not null and @facade is not null .At the moment if @house_type is null it goes to part2
Thank you
CREATE PROCEDURE hpg_spGetSiteInstr
(
@house_type int ,
@facade int
)
AS
IF @house_type IS NOT NULL
IF @facade IS NOT NULL
begin (part1)
SELECT * FROM tbl
WHERE tbl.house_type_id = @house_type
and tbl.facade_id = @facade
end
ELSE
begin (part2)
SELECT *
FROM tbl
WHERE tbl.house_type_id = @house_type
END
GO