declare @PFMMaster nvarchar(64)

SELECT TOP 1
 @PFMMaster = Objects_tbl.ObjectUgMaster_PartFamMemName

FROM dbo.Objects_tbl
where
      Objects_tbl.ProcStateCol03='N'
 And  Objects_tbl.ObjectClass='DS'
 And  Objects_tbl.ObjectFromSiteID='tceng'
 And Objects_tbl.ObjectOwningSiteID='tceng'
 And Objects_tbl.ObjectUgMaster_PartFamMemName<>''
 And  Objects_tbl.ObjectUgMaster_CompCount<=6000
 And  Objects_tbl.ObjectUgMaster_CompCount>=0
 ORDER BY Objects_tbl.ObjectUgMaster_APLevels ASC,
 Objects_tbl.ObjectUgMaster_CompCount ASC,
 Objects_tbl.ObjectLastModDate DESC;

/*
Select * from Objects_tbl
 where (Objects_tbl.ObjectClass = 'DS' and Objects_tbl.ObjectName like (@PFMMaster+'%')) ;
-- UNION
Select * from Objects_tbl
 where Objects_tbl.ObjectUgMaster_PartFamMemName=@PFMMaster ;
*/

Select * from Objects_tbl
 where (Objects_tbl.ObjectClass = 'DS' and Objects_tbl.ObjectName like (@PFMMaster+'%'))
 UNION ALL
Select * from Objects_tbl
 where Objects_tbl.ObjectUgMaster_PartFamMemName=@PFMMaster ;
