Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

As compared to say:

REPLICATE(@padchar, @len - LEN(@str)) + @str

1 Answer

0 votes
by (40.4k points)

It's most recommendable to avoid padding varchar on the left to a certain length. Because it's an inefficient use of SQL.

According to me, you need the padding because you are dealing with a fixed length. Have a look at the given query. 

Query:

right('XXXXXXXXXXXX'+ rtrim(@str), @n)

Here, X is the padding character and @n is the number of characters in the resulting string.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...