I have @depto beachible and I want to make a filter in "select" when @depto is different from blanks
here its my code:
declare @depto as varchar(12)
set @depto='1500'
if @p_depto!='' begin
select distinct p_parte,p_depto from products where
p_type in ('A', 'P') and p_status='A' and p_depto=@p_depto
end
else
select distinct p_parte,p_depto from products where
p_type in ('A', 'P') and p_status='A'
end
I want to put the result in a "CURSOR" somebody knows how doing it? My principal problem its the filter how to filter the information
here its my code:
declare @depto as varchar(12)
set @depto='1500'
if @p_depto!='' begin
select distinct p_parte,p_depto from products where
p_type in ('A', 'P') and p_status='A' and p_depto=@p_depto
end
else
select distinct p_parte,p_depto from products where
p_type in ('A', 'P') and p_status='A'
end
I want to put the result in a "CURSOR" somebody knows how doing it? My principal problem its the filter how to filter the information