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
 General SQL Server Forums
 New to SQL Server Programming
 How to update a data record when defined as money.

Author  Topic 

datamaxster
Starting Member

2 Posts

Posted - 2014-11-23 : 01:03:39
When i try to use the following command;
Update (table name)
set (Field name)='0'
where ID='1449' (1449 location of the record).

The "Field name" value is 875 and i need to edit the value to 0(zero).


It appears an error -
----------------------------
Msg 260, Level 16, State 1, Line 1
Disallowed implicit conversion from data type varchar to data type money, table 'dbname.dbo.table name', column 'field name'. Use the CONVERT function to run this query.

-----------------------------
So if i change the data type from right click design menu to nvarchar(50) can it be edited from the command that i used above?? Any other suggestions ?? Need to know your feedback too??

Thanks & Regards
Datamaxster

mandm
Posting Yak Master

120 Posts

Posted - 2014-11-23 : 08:34:58
This is because you've defined your 0 value as a character by putting the single quotes around it. SQL Server then needs to convert it to money in order to perform the update. Take the single quotes off as follows and it should work.

set (Field name)= 0
Go to Top of Page

datamaxster
Starting Member

2 Posts

Posted - 2014-11-23 : 09:18:27
Thanks it worked.
Go to Top of Page

mandm
Posting Yak Master

120 Posts

Posted - 2014-11-23 : 10:03:13
You're welcome.
Go to Top of Page
   

- Advertisement -