Complicated Export To Text

G

GFB45202

I need to export data from a query. Based on the results in one of the
columns, I need to create a text file for each change in one of the columns.
The data (from HEADER2 example) is dynamic, so hardcoding is not an option.

Is there a way to automate this export?

Query Results

HEADER1 HEADER2
ABC OHIO
ABC UTAH
DEF UTAH
XYZ TEXAS
LMN TEXAS
GHI TEXAS


Desired output will be three files.

File 1 will be OHIO.txt.

File will contain:

HEADER1 HEADER2
ABC OHIO


File 2 will be UTAH.txt.

File will contain:

HEADER1 HEADER2
ABC UTAH
DEF UTAH


File 3 will be TEXAS.txt.

File will contain:

HEADER1 HEADER2
XYZ TEXAS
LMN TEXAS
GHI TEXAS
 
Top