[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using'replace'in SQL

Posted on 2009-05-17
3
Medium Priority
?
190 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
  • 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

834 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