当@UNo为null时,执行“select * from CustomerOrder”;
当@UNo为1时,执行“select * from CustomerOrder where U_No is null”;
当@UNo不为空也不为1时,执行“select * from CustomerOrder where U_No = @UNo”;满足上述条件的完整的存储过程该怎么写?求教!
当@UNo为1时,执行“select * from CustomerOrder where U_No is null”;
当@UNo不为空也不为1时,执行“select * from CustomerOrder where U_No = @UNo”;满足上述条件的完整的存储过程该怎么写?求教!
(
@UNo INT NULL
)
AS
BEGIN
IF @UNo IS NULL
select * from CustomerOrder
ELSE IF @UNo = 1
select * from CustomerOrder where U_No is null
ELSE
select * from CustomerOrder where U_No = @UNo
END
begin
select * from CustomerOrder
endelse
begin
if isnull(@UNo,'')= '1'
begin
select * from CustomerOrder where U_No is null
end
else
begin
select * from CustomerOrder where U_No = @UNo
end
end