Created
July 24, 2019 06:14
-
-
Save dmlogv/836be6888b9ff5269ced3aca0c59c205 to your computer and use it in GitHub Desktop.
RegEx T-SQL Parser for extracting sources and destinations from the INSERT statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (insert (?: \s (?:bulk|into))?) \s | |
| (?(?=openquery) (?: | |
| (openquery) \s \( | |
| (\S+?) \, \s \' .+? \'\) | |
| ) | |
| | (\S+) | |
| ) | |
| .+? | |
| select | |
| (?:.+?(from|join) \s (\S+))+ | |
| (?<i_cl>insert (?: \s (?: into | bulk ))?) \s | |
| (?(?=openquery) (?: | |
| (?<i_oq>openquery) \s \( | |
| (?<i_oq_srv>\S+) \, \s \' | |
| .*? | |
| \'\) | |
| ) | |
| | (?: | |
| (?<i_tbl>\S+) | |
| ) | |
| ) | |
| .*? \s select \s .*? | |
| (?: | |
| (?<f_cl>from) \s | |
| (?(?=openquery) (?: | |
| (?<f_oq>openquery) \s \( | |
| (?<f_oq_srv>\S+) \, \s \' | |
| (?: .+? (?<f_oq_cl>from|join) \s (?<f_oq_tbl>\S+) ) | |
| .* \'\) | |
| ) | |
| | (?: (?<f_tbl>\S+) ) | |
| ) | |
| )+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment