IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_prdctg_details]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_prdctg_details]
GO
create proc [dbo].[mps_g_prdctg_details]
@cmpid int,
--@pcid bigint
@pctag int
as
begin
set nocount on 
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

/* declare @pctype nvarchar(255),@pctag int
select @pctype = pc_type,@pctag =pc_tag from mps_prdctg 
where pc_id = @pcid and pc_cmpid = @cmpid

if @pctype > ''
begin
set @pctype = @pctype + '/%'
select *,(select pc_type from mps_prdctg a where a.pc_id=b.pc_father) as pc_fname from mps_prdctg b where (b.pc_full like @pctype and b.pc_father > 0 and pc_tag = @pctag) or (b.pc_father = @pcid) 
order by b.pc_tag,b.pc_order,b.pc_id,b.pc_level
end */
select *,pc_tag as datagroup,(select pc_type from mps_prdctg a where a.pc_id=b.pc_father) as pc_fname from mps_prdctg b where b.pc_cmpid=@cmpid  and b.pc_tag=@pctag  order by pc_tag,pc_order,pc_level 

set nocount off 
end