I have managed to create some code that takes my SQL (in a cell on my spreadsheet) and it run the SQL on my server. But the SQL I have isn't working. I'm wondering if it's a problem with the difference in languages (JET) etc. I ahve tried both the following but both seem to fail. Cany anyone suggest other options?
This one works:
This one fails:
This fails too:
My Connection String is:
This one works:
Code:
SELECT Inpatient_Ex.HospitalProviderSpellNumber, Inpatient_Ex.SpellStartDateTime, Inpatient_Ex.SpellEndDateTime, LuCustomisableDate.StartDate, LuCustomisableDate.EndDate
FROM Inpatient_Ex INNER JOIN LuCustomisableDate ON (Inpatient_Ex.SpellStartDateTime<LUCUSTOMISABLEDATE.ENDDATE) (Inpatient_Ex.SpellEndDateTime AND>=LuCustomisableDate.StartDate)
WHERE ((Inpatient_Ex.EpisodeNumber)='1')
This one fails:
Code:
SELECT Inpatient_Ex.HospitalProviderSpellNumber, Inpatient_Ex.SpellStartDateTime, Inpatient_Ex.SpellEndDateTime, LuCustomisableDate.StartDate, LuCustomisableDate.EndDate, Iif(LuCustomisableDate.StartDate<INPATIENT_EX.SPELLSTARTDATETIME,INPATIENT_EX.SPELLSTARTDATETIME,LUCUSTOMISABLEDATE.STARTDATE) AS adjStart
FROM Inpatient_Ex INNER JOIN LuCustomisableDate ON (Inpatient_Ex.SpellStartDateTime<LUCUSTOMISABLEDATE.ENDDATE) (Inpatient_Ex.SpellEndDateTime AND>=LuCustomisableDate.StartDate)
WHERE ((Inpatient_Ex.EpisodeNumber)='1')
This fails too:
Code:
SELECT Inpatient_Ex.HospitalProviderSpellNumber, Inpatient_Ex.SpellStartDateTime, Inpatient_Ex.SpellEndDateTime, LuCustomisableDate.StartDate, LuCustomisableDate.EndDate, CASE WHEN LuCustomisableDate.StartDate<Inpatient_Ex.SpellStartDateTime THEN Inpatient_Ex.SpellStartDateTime ELSE LuCustomisableDate.StartDate As adjStart
FROM Inpatient_Ex INNER JOIN LuCustomisableDate ON (Inpatient_Ex.SpellStartDateTime<LuCustomisableDate.EndDate) AND (Inpatient_Ex.SpellEndDateTime>=LuCustomisableDate.StartDate)
WHERE ((Inpatient_Ex.EpisodeNumber)='1')
My Connection String is:
Code:
myConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog=InformationDB;" & _
"Data Source=PURPLE2"