Solved

Using'replace'in SQL

Posted on 2009-05-17
3
182 Views
Last Modified: 2012-05-07
Hi Experts
I have a routine to generate a list of unique diagnoses from some health records, but I need to remove the question marks

Sql = ""
Sql = Sql & "Insert into Distinct_Diagnoses [Desc] "
Sql = Sql & " select distinct [Diagnosis] from PATIENT_PROBLEMS "

is giving me
?Asthma
Asthma
?Stroke
Stroke
etc

The following change to the SQL gives a "type mismatch" error
Sql = Sql & "select distinct '" & (Replace [Diagnosis] , [?], "" ) & "'"

Any other way of doing the necessary "replace''?

Many thanks

0
Comment
Question by:peterdarazs
[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
  • 2
3 Comments
 
LVL 2

Expert Comment

by:d1rtyw0rm
ID: 24405249
Correct me if i'm wrong but it seem that you have duplicated records.

You can simply filter them with a where clause like that :

Sql = ""
Sql = Sql & "Insert into Distinct_Diagnoses [Desc] "
Sql = Sql & " select distinct [Diagnosis] from PATIENT_PROBLEMS WHERE [Diagnosis] NOT LIKE '?%"
0
 
LVL 2

Accepted Solution

by:
d1rtyw0rm earned 500 total points
ID: 24405259
oups ....

Sql = Sql & " select distinct [Diagnosis] from PATIENT_PROBLEMS WHERE [Diagnosis] NOT LIKE '?%'"

Sorry ;P
0
 

Author Closing Comment

by:peterdarazs
ID: 31582324
ok, thanks - that might just be the trick . Many thanks

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

696 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