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 2005 Forums
 Transact-SQL (2005)
 Sum the cubes of a numeric string

Author  Topic 

davidc
Starting Member

26 Posts

Posted - 2007-05-09 : 06:40:39
I need to take a numeric value and add together the cubes of each single digit. The string length may vary from row to row.

As as example the number 1234 has individual cube values of 1 (1 cubed), 8 (2 cubed), 27 (3 cubed) and 64 (4 cubed). The resulting sum of the cubes is then 1+8+27+64 = 100. The same result would occur for 1243.

The purpose is to look for numeric values in a table where the same digits occur in two different rows but in a different order.

How can I create a function to apply to a varchar column to produce my integer result ?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-09 : 06:41:56
This forum is not for posting questions. Please post your question in appropriate forum.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-28 : 08:26:57
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=83295


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-28 : 08:38:54
moved from script library

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -