Another common use case is when we would like to add the ‘0’ characters prefixing depending on available numbers.For an example, if we need to represent digit like as always 6 characters irrespective the actual number by adding “0” (s) to the digit, we can easily achieve with RIGHT() function.
SELECT 'Latheesh' Fullname,Left('Latheesh', 4) AS LeftString,RIGHT('Latheesh', 4) AS RightString;
I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!
Declare @mydigit int Set @mydigit = '34' Select Right('000000'+cast(@mydigit as varchar(6)),6) Set @mydigit = '100' Select Right('000000'+cast(@mydigit as varchar(6)),6)