Home > Mobile >  Teradata SQL query parsing. Identify comennts (using SQL)
Teradata SQL query parsing. Identify comennts (using SQL)

Time:11-29

Im working on teradata log analysis and faced with issue that a lot of queries have comments. Can somebody help in REGEXP_REPLACE defiinition or may be advice some other way how to do it?

So task is to remove/replace query part with (it can be in any position in sql and may repeat):

  1. --text
  2. /* text */

I spent a lot of time on it and stil no good results.

I tried to use REGEXP_REPLACE but faced with problems:

  1. how to difine 'end of line'. for comments difiend as '--text'. Beginning -- till 'end of line'
  2. how to deal with several comments in query?

CodePudding user response:

Findout how to do it:

RegExp_Replace(SqlTextInfo,'[\t\r\n]|(--[^\r\n]*)|(/\*[\w\W]*?(?=\*/)\*/)')

  • Related