Link to home
Create AccountLog in
Avatar of redmission
redmissionFlag for United States of America

asked on

SQL Update - Padding With Leading Zeroes

I have a SQL database table that has some data in it.  I need to update one of the columns, so that they all be a fixed length of 3, with leading zeroes.  So if I have 15 it will be 015, and if I have 3 it will become 003, etc...

The table is called #OLP_AMP and the column is LCTN_NUM (nvarchar).  

I want to write something similiar to
UPDATE #OLP_AMP
SET LCTN_NUM = X

But replace the X with a formula or way to add the leading zeroes.  I'm writing the SQL statement from VB.NET, but I'm not looping through a recordset or anything...I just want to send the SQL statement to the connection to execute.
ASKER CERTIFIED SOLUTION
Avatar of ee_rlee
ee_rlee
Flag of Philippines image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of redmission

ASKER

Thanks a bunch.  I've been Googling this all day, and couldn't find it.  Your solution was 100% perfect! :)