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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, thanks - that might just be the trick . Many thanks
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 '?%"