LPAD in SQL Server
<p>I'm trying to figure out LPAD function in SQL Server. I found some syntax but the result is not what I'm expecting. The column ID is defined as <code>varchar</code>. I want to replicate dependent string '04130' based on the length of ID column. Any hints is highly appreciated. Thanks </p>

<pre><code>SELECT 
    ID,
    RIGHT(REPLICATE('04130', 12)+LEFT(ID, 12), 12) --- (LPAD in sql server)
FROM 
    S_Information_Tab;
</code></pre>

<p>This is the output I'm getting </p>

<pre><code>ID     (No column name)
6452    130041306452
6495    130041306495
</code></pre>

<p>This is the <strong>expected</strong> output:</p>

<pre><code>ID    (No column name)             
6452  041300416452
6495  041300416495
</code></pre>