Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nested if

Status
Not open for further replies.

nat35

Programmer
Nov 10, 2002
86
AU
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
 
IF @house_type IS NOT NULL
begin
IF @facade IS NOT NULL
begin
SELECT * FROM tbl
WHERE tbl.house_type_id = @house_type
and tbl.facade_id = @facade
end

ELSE
begin
SELECT *
FROM tbl
WHERE tbl.house_type_id = @house_type
END
end

IF @house_type IS NULL
begin
SELECT *
FROM tbl
WHERE tbl.house_type_id = @house_type
END
 
Thank you for that Claire
but it does not work
if I exec hpg_spGetSiteInstr '280',''it does not return any
record I know there is a few
Nat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top