select VN.VersionID, FolderName, VI.ItemID, PP.FromType, IC.PreviousID ,ii.ItemID NextID, dbo.ve_GetShortPathFromContentID(CC.ContentID) Location from Contents CC
JOIN VEFN_GetVersionProcedureItems('') VI ON VI.ContentID = CC.ContentID
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
Join Grids GG ON GG.ContentID=CC.ContentID
Join Items IC on VI.ItemID = IC.ItemID
Left  Join Parts PP  ON VI.ItemId = PP.ItemID
Left Join Items II on II.PreviousID = VI.ItemID
where Type not in (20008,20010,20033,20034)
order by versionid, VI.ItemID