faridah27 Posted February 17, 2006 Share Posted February 17, 2006 I have a problem to update a bulk of valueI want to know how to update a bulk of value for example value 123456, 112233, 223344 and many else to become to 8 characters which is 00123456, 00112233, or 00223344...How should I do this at once?I just one to know the syntax that I should use to make all this 6 characters, to become 8 characters using one command only...StaffNo <New StaffNo>123456 00123456112233 00112233223344 00223344Thanks for your concern Link to comment Share on other sites More sharing options...
pulpfiction Posted February 17, 2006 Share Posted February 17, 2006 This should work, replace the number '123456' with the field,SELECT RIGHT('00' + CONVERT(VARCHAR(6), '123456'), 8) AS LeftPaddedWithTwoZero Link to comment Share on other sites More sharing options...
faridah27 Posted February 20, 2006 Author Share Posted February 20, 2006 Its work, but not the solution that i want...I've found the solutionselect * from <tablename> set <columnname>= '00' + <columname>Thanks for your concern... Link to comment Share on other sites More sharing options...
arief_anang Posted March 8, 2006 Share Posted March 8, 2006 Or you can use this script as an altenativeUPDATE tablename SET columnname=CONCAT(00,columnname)orUPDATE tablename SET columnname=00+columnnameRegards,Anang Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now