cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How do I preserve line number ordering with OPENSTRING?

Breck_Carter
Participant
1,592

There's no doubt OPENSTRING is really cool... but how do I preserve the input row/line number ordering?

With LOAD TABLE, this technique works:

DECLARE LOCAL TEMPORARY TABLE raw_text (
   line_number          BIGINT NOT NULL 
                           DEFAULT AUTOINCREMENT
                           PRIMARY KEY CLUSTERED,
   line_text            LONG VARCHAR NOT NULL DEFAULT '' )
   NOT TRANSACTIONAL;

LOAD TABLE raw_text ( line_text )
   USING VALUE @whatever
   DEFAULTS ON 
   DELIMITED BY '' 
   ESCAPES OFF 
   HEXADECIMAL OFF 
   QUOTES OFF 
   STRIP OFF;

Accepted Solutions (1)

Accepted Solutions (1)

johnsmirnios
Advisor
Advisor

select rowid( tab ), * from openstring( VALUE @whatever ) WITH( ...schema... ) tab

Answers (0)