Results 1 to 3 of 3

Thread: MSSQL 2K : Export Help Needed

  1. #1
    Join Date
    Apr 2005
    Posts
    4

    Question MSSQL 2K : Export Help Needed

    Is there a simple way to write the contents of table1 to a file as displayed below?

    Table1

    column1 column2 column3 column4

    a b c d
    1 2 3 4
    xx gg cc ff

    I need the data to be in a format like this:

    a
    b
    c
    d

    1
    2
    3
    4

    xx
    gg
    cc
    ff


    I can only get dts to export / display the data the same way the column does and I have no idea on how to do write a file reformat program.
    Please Help.

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    create table Table1(column1 varchar(10),column2 varchar(10),column3 varchar(10),column4 varchar(10))
    insert into Table1 select 'a','b','c','d'
    insert into Table1 select '1','2','3','4'
    insert into Table1 select 'xx','gg','cc','ff'

    select * from Table1

    --results
    column1 column2 column3 column4
    ---------- ---------- ---------- ----------
    a b c d
    1 2 3 4
    xx gg cc ff

    select column1+char(13)+char(10)+column2+char(13)+char(10 )+column3+char(13)+char(10)+column4+char(13)+char( 10)
    as Column1 from Table1

    --results
    Column1
    -------
    a
    b
    c
    d
    1
    2
    3
    4
    xx
    gg
    cc
    ff

  3. #3
    Join Date
    Apr 2005
    Posts
    4
    That is so helpful. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •