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 |
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2009-11-26 : 00:36:20
|
| Hi,I have one table LP_ExpertationId IDENTITYName Varchar(128)Price nvarchar(8)Table values Id Name Price1 A 12 B 53 C .54 d 0.6select (CASE WHEN Price = '' THEN 0 ELSE Price END) as Price from LP_Expertationwe got the following error message Msg 245, Level 16, State 1, Line 1Conversion failed when converting the nvarchar value '.5' to data type int.kindly advice this oneif you need more clarification means i will explain youThanks an advance |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-11-26 : 00:42:39
|
why are you storing Price in a string column ? You should use numeric or decimal data type for the Price KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-11-26 : 00:47:25
|
| select (CASE WHEN Price = '' THEN '0' ELSE Price END) as Price from @i |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-11-26 : 00:47:38
|
| Try thisselect (CASE WHEN Price = '' THEN '0' ELSE Price END) as Price from LP_ExpertationSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2009-11-26 : 00:55:06
|
quote: Originally posted by senthil_nagore Try thisselect (CASE WHEN Price = '' THEN '0' ELSE Price END) as Price from LP_ExpertationSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/
Dear senthil_nagore,your query is working thanks a lot |
 |
|
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2009-11-26 : 00:56:19
|
quote: Originally posted by khtan why are you storing Price in a string column ? You should use numeric or decimal data type for the Price KH[spoiler]Time is always against us[/spoiler]
Dear khtan,we are maintain the lot of values its cannot easy convert another data typethanks an advance |
 |
|
|
|
|
|