Hi all,
I have table structure and stored proc which has two queries to return from 2 dataset from the same table:
I was looking to simplify these two queries into one for better standard practice.
Please help...
Any input would be much appreciated.
Thanks,
I have table structure and stored proc which has two queries to return from 2 dataset from the same table:
Code:
TABLE STRUCTURE
parent children column1 column2 column3
1 A test1 test2 test3
1 B test1 test2 test3
1 C test1 test2 test3
2 D test1 test2 test3
2 E test1 test2 test3
3 F test1 test2 test3
Code:
declare @childrenid int,
@parentid int
if @childrenid is not null
begin
select
column_1,
column_2,
column_3
where table.children = @childrenid
end
else
begin
select
column_1,
column_2,
column_3
where table.parent = @parentid
end
I was looking to simplify these two queries into one for better standard practice.
Please help...
Any input would be much appreciated.
Thanks,