• This is a possible solution. Be sure to understand how does it work and ask any questions that you have.

    SELECT Reference,

    PARSENAME( r.dotted, 3) + '.' +

    MAX( PARSENAME( r.dotted, 2)) OVER (PARTITION BY (SELECT NULL)) + '-' +

    PARSENAME( r.dotted, 1)

    FROM #SampleData s

    CROSS APPLY (SELECT REPLACE( Reference, '-', '.') dotted) r

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2