IanWaterman
Programmer
SQL Server 2008
I need to concatenate a String and number field to yield a fixed length string
Currently I have
"vw_CreditLossRatio"."ClaimYear"+(Cast("vw_CreditLossRatio"."ClaimNumber" as varchar) "ClaimRef"
If Claim number is 1 or 340 I get
BK1 or BK340 respectively.
However, I would like to return
BK00001 or BK00340 is that possible.
On searching this site I found following solution, but as this was a 2003 posting I was wondering if there was a neater solution
replicate('0', 5 - len(Cast("vw_CreditLossRatio"."ClaimNumber" as varchar))) + Cast("vw_CreditLossRatio"."ClaimNumber" as varchar)
Thank you
Ian
I need to concatenate a String and number field to yield a fixed length string
Currently I have
"vw_CreditLossRatio"."ClaimYear"+(Cast("vw_CreditLossRatio"."ClaimNumber" as varchar) "ClaimRef"
If Claim number is 1 or 340 I get
BK1 or BK340 respectively.
However, I would like to return
BK00001 or BK00340 is that possible.
On searching this site I found following solution, but as this was a 2003 posting I was wondering if there was a neater solution
replicate('0', 5 - len(Cast("vw_CreditLossRatio"."ClaimNumber" as varchar))) + Cast("vw_CreditLossRatio"."ClaimNumber" as varchar)
Thank you
Ian