I found a solution for my problem, so I'll share it with you guys 😉
select
substring(inv_machine.name,1,charindex('_',inv_machine.name,1)-1) as Machine_Name,
from
inv_machine
where
CHARINDEX('_', inv_machine.name) > 0
This code will look at the length of my string and delete text from the _ until the end.
Thnx for the support.