Create view for the form

Hi All,

Need to create a form with a two joined table(BOM and BOM Version) as a datasource to display a data by a filter. I could create a View that includes the fields i need. I have a SQL query which I’m able to execute in MS managment studio:

DECLARE @ITEMID NVARCHAR(20)
SET @ITEMID =‘wx202d-t’

SELECT a.Itemid,
c.BOMID,
c.NAME,
c.ACTIVE
FROM BOM a

INNER JOIN BOMVERSION c
ON a.ITEMID = c.ITEMID

WHERE a.BOMID IN(select b.BOMID from BOMVERSION b where b.itemid = @ITEMID)
GROUP BY a.Itemid,
c.BOMID,
c.NAME,
c.ACTIVE

what would be the best approch to create a view or creating a dynamic query using x++

Thanks.