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 2000 Forums
 SQL Server Development (2000)
 select query DBNULL for money field using Convert

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2006-06-01 : 12:51:03
I am getting the following error: i am trying to show null value when there is no data in the field: it is a money datatype:

Implicit conversion from data type varchar to money is not allowed. Use the CONVERT function to run this query.

************query:**************
select isnull(rf.EstimatedCost,'''') as EstimatedCost from costdetailstable

Can you please tell me what am i doing wrong in the above query.

Thank you very much for the info.

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-06-01 : 13:02:31
[code]Create table #t(F1 varchar(10), EstimatedCost money)

Insert into #t values ('aa',24.00)
Insert into #t values ('bb',Null)
Insert into #t values ('cc',0.00)
Insert into #t (F1) values ('dd')

--Select F1, isnull(EstimatedCost,' ') from #t
-- The above doesn't work as it tries to convert Money Type to a Varchar

Select F1, isnull(Convert(Varchar(100),EstimatedCost),' ') from #t

drop table #t[/code]

Srinika
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-02 : 02:26:59
You can handle this at client application or use 0 instead of ''

select isnull(rf.EstimatedCost,0) as EstimatedCost from costdetailstable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -