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

Using LIKE in SQL to compare Money type field to a string

hi

i have the following sql statement
" select bla bla bla...... where  Price  " like '%" & Request.form("selectvalue") & "%'"  

This sql statement works Ok in ACCESS but in SQL 2000 i get the following error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type money to varchar is not allowed. Use the CONVERT function to run this query.

Any idea how to fix that ?
Thx
0
humer2000
Asked:
humer2000
  • 3
1 Solution
 
HilaireCommented:
try

" select bla bla bla...... where  CONVERT(VARCHAR(20), Price)  " like '%" & Request.form("selectvalue") & "%'"  
0
 
HilaireCommented:
or like this (shorter but does exactly the same)

" select bla bla bla...... where  CAST(Price as VARCHAR)  " like '%" & Request.form("selectvalue") & "%'"  
0
 
HilaireCommented:
the slight differences between the two syntaxes

- <BOL>CAST is based on the SQL-92 standard and is preferred over CONVERT.</BOL>
- Casting money datatype to varchar uses varchar(30) as default target datatype
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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