VBdotnet2005
asked on
select data field from a table, if exists
I want to select clientrefid from table1 and if it does not return anything I want to select clientrefid from table2 in one store procedure. What should I do?
create procedure select_clientrefid
@clientrefid varchar(7)
select clientrefid from table1
if return nothing
then select clientrefid from table2
create procedure select_clientrefid
@clientrefid varchar(7)
select clientrefid from table1
if return nothing
then select clientrefid from table2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@clientrefid varchar(7)
)
as
set nocount on;
if exists(select 1 from table1 where clientrefid = @clientrefid)
begin
select clientrefid from table1
end
else
begin
select clientrefid from table2
end
set nocount off
go