Home Forums SQL Server 2005 T-SQL (SS2K5) Controlling column order when reading text file based on schema.ini and OPENDATASOURCE RE: Controlling column order when reading text file based on schema.ini and OPENDATASOURCE

  • for larger number of columns - copy and paste the header row into your select command, then you can find and replace the pipe symbol with ],[ and then finish off with a leading [ and trailing ]

    col1|col2|col3|col4

    becomes

    [col1],[col2],[col3],[col4]

    or if you want to be really lazy, use something like textpad which has regex search and replace, you can then replace the pipe symbol with:

    ],

    [

    so your columns are listed nicely.

    or use an online tool like:

    http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl

    to format the query.

    remember, if you're working as a programmer than anything can be programmed, even the sometimes tedious task of programming