I want to know whether a digit is decimal or int [Resolved]

Posted by Amritha444 under Sql Server on 6/18/2011 | Points: 10 | Views : 3779 | Status : [Member] | Replies : 3
Hi all

I want to know whether a digit is decimal or int

i know in front end we can use indexof method but how to do ti in back end

datatype for the field is decimal but some rows contains 1.00 and others 1.50 i wnat to distinguish those fields
if(DayTotal.IndexOf('0') >0)
{
1.5
}
else
{
1.00
}

how to make it in back end

Thanks in advance




Responses

Posted by: Ndebata on: 6/20/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi
First of all if you are storing the value in a particular type (int/decimal), it will be of that type.
Else if you are having a string that may contain a decimal or int, you can find it using the same logic whether decimal point is there in that string or not.
declare @myvalue nvarchar(50)

set @myvalue='10'
IF(CHARINDEX('.',@myvalue)=0 )
Print 'INT'
ELSE
Print 'DECIMAL'

Thanks,
Debata


Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vilasgite080 on: 6/19/2011 [Member] Starter | Points: 25

Up
0
Down
HI..
RIGHT CLICK ON TABLES IN SQL SERVER... JUST CLICK ON MODIFY...
THERE WERE YOU WILL SEE DATATYPES....... :)
----------------------------------------------------------------------------
MARK AS ANSWER! IF ITS HELPS YOU.

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Amritha444 on: 6/20/2011 [Member] Starter | Points: 25

Up
0
Down
THANKS Ndebata


Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response