SQL Server : LENGTH() inside of REPLICATE() -
i have sql server table columns lvl
, title
. need insert "-" in front of title every character in lvl
field.
as example: if lvl = 111
title should become --- title
.
i can edit following sql string. there no possibility create other functions or likewise.
select replicate('_', { fn length(lvl) }) + ' ' + title title documents
my problem is, length()
function doesn't work inside replicate()
function. know why or how solve problem?
thank you.
try this:
select replace(lvl, '1', '-') + ' ' + title title documents
simply take lvl
column, , replace instances of 1 whatever character want, concatenate title end of result.
Comments
Post a Comment