TSQL varchar string manipulation

后端 未结 5 1232
失恋的感觉
失恋的感觉 2021-01-14 22:36

I have a variable which contains the following string: AL,CA,TN,VA,NY

I have no control over what I get in that variable (comes from reporting services)

I

5条回答
  •  盖世英雄少女心
    2021-01-14 23:15

    For a more generic answer, when you don't know what your output will look like exactly, use regular expressions.

    This would let you you match on something like [A-Z]{2} and replace it with '$&'.

    A commenter suggested this is overkill for this task - agreed, if you can guarantee you will always get a string like that. However, other people find these question pages later with similar, but not exact, problems, so other options are helpful to have.

提交回复
热议问题