Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have a bunch of numbers some 3 digits, some 4 digits, some 5 digits and i need to add a decimal after the 3rd digit for the numbers 4 and 5 digits long.ex456245645657 i need them to look like this 456245.6456.57Any help would be greatly appreciated.
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2010-01-28 : 09:10:56
What is the datatype of the column that holds the values?Should it be an update to the table or just in display?Why do you need to do this?No, you're never too old to Yak'n'Roll if you're too young to die.
singularity
Posting Yak Master
153 Posts
Posted - 2010-01-28 : 09:18:34
Just out of curiosity, are these ICD9 diagnosis codes?Maybe something like this:
select case when len(yourfield) = 5 then left(yourfield,3) + '.' + right(yourfield,2) when len(yourfield) = 4 then left(yourfield,3) + '.' + right(yourfield,1) else yourfield endfrom yourtable
needhelp6184
Starting Member
5 Posts
Posted - 2010-01-28 : 10:28:38
I need to update and datatype is varchar
needhelp6184
Starting Member
5 Posts
Posted - 2010-01-28 : 10:29:33
Singularity i think i can use what you posted and go from there. i appreciate that.