Jeśli chcesz wszystko po ostatnim _ , a następnie użyj:
select right(db_name(), charindex('_', reverse(db_name()) + '_') - 1)
Jeśli chcesz wszystkiego wcześniej, użyj left() :
select left(db_name(), len(db_name()) - charindex('_', reverse(db_name()) + '_'))