I have a table that has a column that is an nvarchar
. I would like to update that column for any rows that currently have a value and only if their value is less than 1,000.
Pseudo code:
UPDATE TABLE_NAME
IF (PARSE(TABLE_NAME.COLUMN) < 1000)
SET TABLE_NAME.COLUMN = ADD-LEADING-ZEROS(TABLE_NAME.COLUMN)
ELSE
do nothing
So basically, if the column contains the value "123"
I would like to update it to be "0123"
. If it's "12"
I would like to update it to be "0012"
, etc.
I'm aware of how to pad leading 0s but I'm not sure how to incorporate it into an update statement since I am still pretty new to sql.