I work on SQL server 2012 i face issue I need to convert characters and numbers to underscore "_"
and after that concatenate it based on length of number or characters
so if one character or one number will be _
so if two character or two number will be __
so if three character or three number will be ___
etc
so How to make select query do above on test sample below
create table portionstable(PortionKey nvarchar(20))
insert into portionstable(PortionKey)
values
('123'),
('abc'),
('a'),
('ab'),
('12')
select * from portionstable___________what I try but not workingselect concat(replace(PortionKey,PortionKey,'_' )) as portionkeyfrom portionstable
so how to do it