Appending Values In String Using RIGHT () In Sql Server

Praveen Singh         No comments


Suppose, we have to append some values in a given string or a number to make it a certain length (like 10 character ) string.

This example will give you clear idea...

We have a value of 7 characters but the requirement is of 10 character length string and appending zeroes in front if the length is not of 10 characters.So, we can use the trick as mentioned in the above screenshot.

Now, let's discuss about one particular situation where this trick may fail...

So, you can see here.. appending doesn't happen here..
To make it work, we have to use LTRIM(RTRIM()) to remove extra spaces from string...

Got our zeroes back !!! :)

Published by Praveen Singh

A blogger by passion.You can find me tucked in my bed and blogging on weekends when not roaming around. Besides blogging, I love music and you can find my songs on my fb page:PraveenUnplugged
Follow on Youtube : Videos On Latest Happenings |ThingsToKnow
Follow us Talend In Action

0 responses:

© 2015 Techie's House. Designed by Bloggertheme9