Assume i have 4.9 value.
I would like to split 4 and .9 ... How can i do it?
I could isolate 4 by using FLOOR(). What about the .9? How can i isolate it?
I'm using t-sql sql server 2005/2008
Assume i have 4.9 value.
I would like to split 4 and .9 ... How can i do it?
I could isolate 4 by using FLOOR(). What about the .9? How can i isolate it?
I'm using t-sql sql server 2005/2008
Declare @dec decimal(8,2)
Set @dec = 23.98
Select Left(@dec, CharIndex('.',@dec)-1) as 'LeftPortion',
RIGHT(@Dec, len(@dec) - CharIndex('.',@dec)) as 'RightPortion'
The easiest i can think would be
SELECT IntegerPart = cast(4.9 AS int), DecimalPart = 4.9 - cast(4.9 AS int)
Take a look at the parsename function. I think the code below will produce the desired results. select parsename(4.9,2) gives the 4 select parsename(4.9,1) gives the 9 The output of parsename can be directly used as a number such that select parsename(4.9,2)* 2 give the vaule 8