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.
Author |
Topic |
itnagaraj
Yak Posting Veteran
70 Posts |
Posted - 2010-08-05 : 04:40:27
|
How to Convert Null to Float in SQL Server 2005.For EaxmpleJuly Aug---- ---215 NullHow to add these two values but data type is float.V.NAGARAJAN |
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-08-05 : 05:00:06
|
NULL Refers NOTHINGYou may store NULL in any datatype.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
itnagaraj
Yak Posting Veteran
70 Posts |
Posted - 2010-08-05 : 05:03:09
|
Hi Vaibav,i want sql statement.no need suggestion or explanationV.NAGARAJAN |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-08-05 : 05:05:02
|
Do you have July Aug Sep Oct & so on as columns ???Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
Kristen
Test
22859 Posts |
Posted - 2010-08-05 : 05:09:33
|
SELECT CONVERT(float, NULL) AS MyColumnNamewill give you a NULL in a Float datatype.Might help if you explain the underlying problem you are trying to solve though. |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-08-05 : 05:16:58
|
quote: Originally posted by Kristen SELECT CONVERT(float, NULL) AS MyColumnNamewill give you a NULL in a Float datatype.Might help if you explain the underlying problem you are trying to solve though.
I think he needs addition of July+Aug & the resultset be saved in float datatype.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-08-05 : 05:18:02
|
quote: Originally posted by itnagaraj Hi Vaibav,i want sql statement.no need suggestion or explanationV.NAGARAJAN
Please dont make us try for spoon feedingWhats wrong with that ?Why need to convert ?INSERT INTO YourTable(July, Aug) VALUES(215,NULL)Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
itnagaraj
Yak Posting Veteran
70 Posts |
Posted - 2010-08-05 : 05:23:59
|
I Wrote SQL for Select Query:Select Jul,Aug,(Jul+Aug) As Total From Commodity.Pls Modify and reply itI want result for the following formatJul Aug Total215 NULL 215V.NAGARAJAN |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-08-05 : 05:28:28
|
quote: Originally posted by itnagaraj I Wrote SQL for Select Query:Select Jul,Aug,(Jul+Aug) As Total From Commodity.Pls Modify and reply itI want result for the following formatJul Aug Total215 NULL 215V.NAGARAJAN
Select Jul,Aug,Convert(float,(IsNULL(Jul,0)+IsNULL(Aug,0))) As Total From CommodityLimitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
Kristen
Test
22859 Posts |
Posted - 2010-08-05 : 05:40:33
|
If the columns [Jul] and [Aug] are already FLOAT datatype then no need for the CONVERT. Just use IsNull() or, my preference, COALESCE() to convert any NULL values to 0Select Jul, Aug, COALESCE(Jul, 0.0) + COALESCE(Aug, 0.0) As Total From Commodity |
 |
|
|
|
|
|
|