[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

Using'replace'in SQL

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
peterdarazs
Asked:
peterdarazs
  • 2
1 Solution
 
d1rtyw0rmCommented:
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
 
d1rtyw0rmCommented:
oups ....

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

Sorry ;P
0
 
peterdarazsAuthor Commented:
ok, thanks - that might just be the trick . Many thanks

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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