• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1626
  • Last Modified:

use the convert function to run this query

Hi,

 I am a beginner, so be very simplistic with me, ok?

 I am trying to run this query:

update orders
set subtotal='59'
where id=47

And I get this:
disallowed implicit conversion from data type varchar to data type money. use the convert function to run this query.

 how do I do this? thanks!


0
mel150
Asked:
mel150
  • 3
  • 2
1 Solution
 
bruintjeCommented:
Hi mel150,

if the datatype of the column subtotal is numeric you don't need to use the quotes

try
update orders
set subtotal=59
where id=47

hope this helps a bit
bruintje
0
 
bruintjeCommented:
putting a value into ' and ' means sql server is seeing it as a varchar meaning text or string type, the data column subtotal is of a numeric type money so it will not allow you to put a string into a numeric field

if you want to do that you need to convert the value in a function like

update orders
set subtotal=CONVERT(money,'59')
where id=47
0
 
mel150Author Commented:
Thanks very much!! I didn't try the first one, but the second one worked!! Thanks so much!
0
 
bruintjeCommented:
glad i could help, but i should thank you for pushing me over to the SQL Server master level ;-)
0
 
mel150Author Commented:
Congratulations! Glad I could be of service. :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now