[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2004-11-02
3
Medium Priority
?
475 Views
Last Modified: 2008-03-03
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
Comment
Question by:humer2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 26

Expert Comment

by:Hilaire
ID: 12473263
try

" select bla bla bla...... where  CONVERT(VARCHAR(20), Price)  " like '%" & Request.form("selectvalue") & "%'"  
0
 
LVL 26

Accepted Solution

by:
Hilaire earned 2000 total points
ID: 12473301
or like this (shorter but does exactly the same)

" select bla bla bla...... where  CAST(Price as VARCHAR)  " like '%" & Request.form("selectvalue") & "%'"  
0
 
LVL 26

Expert Comment

by:Hilaire
ID: 12473357
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question