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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 convert to height

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2005-08-10 : 12:55:57
I can I convert "5 feet 3 inches" to 63( inches) in SQL


spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-10 : 13:03:15
select feet*12 + inches

Go with the flow & have fun! Else fight the flow
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2005-08-10 : 13:10:36
You need to parse your string. You could have a look on the forum for a general purpose function to do it for you.
Alternatively, so long as your data is consistent, this will do the trick:
select 
left(mt.MyCol, charindex(' feet ', mt.MyCol)-1) * 12 +
right(replace(mt.MyCol, ' inches', ''), charindex(' ', reverse(replace(mt.MyCol, ' inches', '')))-1)
from
dbo.MyTable AS mt


Mark
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2005-08-10 : 13:12:03
Nice one spirit!

Mark
Go to Top of Page
   

- Advertisement -