Sample Header Ad - 728x90

Converting varchar to decimal with truncate

2 votes
1 answer
2783 views
I have a column called latitude which is currently varchar(20) I want to convert it to DECIMAL(9,6) However the data stored inside the column is greater than 6 decimal points i.e. 48.123456891123456 the table in question has over 50 billion rows and is a 24/7 database with no downtime and uses partitioning by month (SQL server 2017 enterprise) How would I achieve the conversion as its too big for 6 decimal points. I was thinking of creating a copy of the column and renaming when converted, however i'm not sure how i would achieve the truncate to 6 decimal points
Asked by Quade (321 rep)
Apr 12, 2023, 12:25 PM
Last activity: Apr 13, 2023, 07:22 AM