Function RemoveSQLComments(sSQL) as string
'This function will remove /* from passed sql lPtr = instr(sSQL,"/*" If lPtr > 0 Then 'continue Else RemoveSQLComments = sSQL Exit Function End If sFixed = sSQL Do Wile lPtr > 0 lEndComment = InStr(lPtr, sFixed, "") if lEndComment = 0 Then Msgbox " invalid SQL, opening comment no closing" end if sFixed = left(sFixed, lPtr - 1) & " " & Mid(sFixed, lEndComment +2) lPtr = InStr(lPtr, sFiexed, "/*") Loop 'Remove end characters that aren't needed and cause issues for i = Len(sFixed) to 1 step -1 sChar = Mid(sFixed, i, 1) If sChar = " " Or sChar = vbCR or sChar = vbLF Then Else Exit For End if Next sFixed = Mid(sFixed, 1, i) RemoveSQLComments = sFixed End Function |