Link to home
Start Free TrialLog in
Avatar of peterdarazs
peterdarazs

asked on

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

Avatar of d1rtyw0rm
d1rtyw0rm
Flag of Canada image

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 '?%"
ASKER CERTIFIED SOLUTION
Avatar of d1rtyw0rm
d1rtyw0rm
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peterdarazs
peterdarazs

ASKER

ok, thanks - that might just be the trick . Many thanks