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.

Related questions

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


Categories

...