Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do we add the truncated digit to the column values in SQL?

For example the column name is digits and it has values as

Digits
123
234

The length of column digit should be 4 and the last digit truncated was 0.
I have to add the 0 to all the truncated values.
So that the column digit should have values as after adding 0 in the end.

digits
1230
2340

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want to append a random digit to all the values in column Digits, you could do :

UPDATE TblName SET Digits = CAST(CAST(Digits AS VARCHAR) + '0' AS INT)

And you can replace ‘0’ with whatever digit you want to append?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading