How do I remove the digits from the left and right side in SQL Server? -


originally claim number looks like. 000000165130 has 12 digits. i'd remove zeros on left side , last 0 on right side making 16513.

select [policy number], left([claim number],11 ) [claim number] dw.claimdata [policy number] = 'p000463500'

policy number   [claim number] p000463500      00000016513 

but how remove 6 zeros on left side?

assuming fixed-width, can use right.

right(left([claim number],11), 5) 

alternately, if number of zeros variable, cast integer:

cast(left([claim number], 11) int) 

and if need string instead:

cast(cast(left([claim number], 11) int) varchar(10)) 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -