sql server - query to remove first value from " For XML PATH " -
i have query :
select ','''+ aa.kodeverifikasi +'''' tverifikasipofakturheader aa (nolock) inner join tverifikasipofakturdetail bb (nolock) on aa.kodeverifikasi=bb.kodeverifikasi aa.kodepo='ts/01/15/00183' group aa.kodeverifikasi order aa.kodeverifikasi xml path ('')
and return :
,'val6','val4','val5','val9'
but want remove first character "," , want return :
'val6','val4','val5','val9'
when using substring : substring(','''+ aa.kodeverifikasi +'''', 2, 8000) return : 'val6''val4''val5''val9'
please me,,, , thanks...
here 1 way using left
function. append , @ end , remove using left
function.
select left(result, len(result) - 1) (select '''' + aa.kodeverifikasi + ''',' tverifikasipofakturheader aa (nolock) inner join tverifikasipofakturdetail bb (nolock) on aa.kodeverifikasi = bb.kodeverifikasi aa.kodepo = 'ts/01/15/00183' group aa.kodeverifikasi order aa.kodeverifikasi xml path ('')) (result)
or can wrap current query in stuff
function , trim first character
Comments
Post a Comment