Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2006
    Posts
    3

    Unhappy Unanswered: Exporting sql table data to csv format

    Hi
    I am trying to export an table data to csv format. The problem here is the table columns are dynamic. The DTS exports only the columns available during the DTS design time and it ignores if any new columns are added after the design. I need solution for this asap.
    Thanks
    SqlJerin

  2. #2
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Use BCP to do that,or you could achieve this using the command line utilities like isql.exe and osql.exe.
    I think that will solve your problem...
    From command prompt:
    osql.exe -S YourServerName -U sa -P secretcode -Q "Put your query" -o "E:\output.csv"

    From T-SQL:
    EXEC master..xp_cmdshell 'osql.exe -S YourServerName -U sa -P secretcode -Q "put your query" -o "E:\output.csv"'
    Last edited by rudra; 04-04-06 at 04:24.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by sqljeba
    Hi
    I am trying to export an table data to csv format. The problem here is the table columns are dynamic. The DTS exports only the columns available during the DTS design time and it ignores if any new columns are added after the design. I need solution for this asap.
    Thanks
    SqlJerin
    A better question is: Why is your schema changing after the design phase?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    While there might be a good reason for this, it makes me nervous. What kind of changes are you making to the schema on an ongoing basis, and what is the underlying (business) reason for making those changes? This sounds like a problem in search of a victim to me.

    -PatP

  5. #5
    Join Date
    Apr 2006
    Posts
    3
    Hello Rudra
    Thanks for your immediate reply. The BCPs are not working in this context as it generates ununiform data in the csv file and it doesn't provide column headers. I prefer dynamic DTS export solutions.
    Thanks
    SqlJeba

  6. #6
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by sqljeba
    Hello Rudra
    The BCPs are not working in this context as it generates ununiform data in the csv file and it doesn't provide column headers. Thanks
    SqlJeba
    yea,that will not help you,dynamic columns right..ok this can help you a bit
    link

    it doesn't provide column headers.
    You haven't mentioned column header in your first post,anyway
    Last edited by rudra; 04-05-06 at 08:19.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

Posting Permissions

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