这很丑陋,可能性能不是很好,但是:
select
page_num,
case
when page_num like '%A' then substring(page_num, 1, len(page_num)-1) + '.01'
when page_num like '%B' then substring(page_num, 1, len(page_num)-1) + '.02'
when page_num like '%C' then substring(page_num, 1, len(page_num)-1) + '.03'
when page_num like '%D' then substring(page_num, 1, len(page_num)-1) + '.04'
when page_num like '%E' then substring(page_num, 1, len(page_num)-1) + '.05'
when page_num like '%F' then substring(page_num, 1, len(page_num)-1) + '.06'
when page_num like '%G' then substring(page_num, 1, len(page_num)-1) + '.07'
when page_num like '%H' then substring(page_num, 1, len(page_num)-1) + '.08'
when page_num like '%I' then substring(page_num, 1, len(page_num)-1) + '.09'
when page_num like '%J' then substring(page_num, 1, len(page_num)-1) + '.10'
when page_num like '%K' then substring(page_num, 1, len(page_num)-1) + '.11'
when page_num like '%L' then substring(page_num, 1, len(page_num)-1) + '.12'
when page_num like '%M' then substring(page_num, 1, len(page_num)-1) + '.13'
when page_num like '%N' then substring(page_num, 1, len(page_num)-1) + '.14'
when page_num like '%O' then substring(page_num, 1, len(page_num)-1) + '.15'
when page_num like '%P' then substring(page_num, 1, len(page_num)-1) + '.16'
when page_num like '%Q' then substring(page_num, 1, len(page_num)-1) + '.17'
when page_num like '%R' then substring(page_num, 1, len(page_num)-1) + '.18'
when page_num like '%S' then substring(page_num, 1, len(page_num)-1) + '.19'
when page_num like '%T' then substring(page_num, 1, len(page_num)-1) + '.20'
when page_num like '%U' then substring(page_num, 1, len(page_num)-1) + '.21'
when page_num like '%V' then substring(page_num, 1, len(page_num)-1) + '.22'
when page_num like '%W' then substring(page_num, 1, len(page_num)-1) + '.23'
when page_num like '%X' then substring(page_num, 1, len(page_num)-1) + '.24'
when page_num like '%Y' then substring(page_num, 1, len(page_num)-1) + '.25'
when page_num like '%Z' then substring(page_num, 1, len(page_num)-1) + '.26'
when page_num like '%-%' then
substring(page_num, 1, charindex('-', page_num)-1) + '.' +
cast((26+cast(substring(page_num, charindex('-', page_num)+1, len(page_num)) as int)) as varchar(12))
else page_num + '.00'
end
from pages
有关我正在测试的完整架构,请参阅SQL Fiddle 。
也就是说,我强烈建议将您的架构更新为包含规范化页码的内容,并在将其转换为表格的过程中。