I have a column that is a maximum size of 9 characters and I want to do a query that will look at all rows which are less than 9. This:
SELECT *
FROM tEmpCourseAssoc
WHERE ({ fn LENGTH(EmployeeID) } < 9)
Now I want to add zeros to the front of the column EmployeeID if it's less than 9 characters so it adds up to nine characters. For example if the column EmployeeID is 1234567 it would get updated to 001234567 and if it's 12345678 it would get updated to 012345678
I think it's something like:
SELECT RIGHT('0000000' + CAST(myField AS VARCHAR), 9)
But I'm not sure how to implement this. I plan on excuting the query straight from Enterprise Manager. The column EmployeeID is type varchar(10)