If you want everything after the last _
, then use:
select right(db_name(), charindex('_', reverse(db_name()) + '_') - 1)
If you want everything before, then use left()
:
select left(db_name(), len(db_name()) - charindex('_', reverse(db_name()) + '_'))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…