fork download
  1. text = r"""SELECT
  2. Involved_Party_ID=pt.ProgramId,
  3. Involved_Party_Type=2,
  4. First_Name=REPLACE(REPLACE(REPLACE(pt.ProgramName, '|', '/'), CHAR(10), ' '), CHAR(13), ' '),
  5. Registration_Status=pt.RegistrationStatus,
  6. Involved_Party_Status=CONVERT(SMALLINT, pt.ProgramStatus),
  7. Creation_Date=pt.CreationDate,
  8. Incorporation_Country=CONVERT(VARCHAR(50), CASE WHEN pd.IncorporationCountry='UK' THEN 'GB' ELSE pd.IncorporationCountry END),
  9. FROM
  10. SomeTable AS pt
  11. GO"""
  12. for line in iter(text.splitlines(False)):
  13. if line.strip().startswith("SELECT"):
  14. continue
  15. elif line.strip().startswith("FROM"):
  16. break
  17. else:
  18. result = line.strip().split("=", 1)[0]
  19. print(result)
Success #stdin #stdout 0.03s 9180KB
stdin
Standard input is empty
stdout
Involved_Party_ID
Involved_Party_Type
First_Name
Registration_Status
Involved_Party_Status
Creation_Date
Incorporation_Country