sql - Substring only if string length > 2 -


i wondering if possible substring if string length > 2?

here sample statement:

select substring(abresc, 1, 2) + '-' + substring(abresc, 3, 5) abresc table

however, fields 2 chars long wondering if possible substring when longer 2 chars?

you use case

select abresc =     case when len(abresc) > 2         substring(abresc, 1, 2) + '-' + substring(abresc, 3, 5)        else  abresc end   table 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -