Results 1 to 6 of 6

Thread: Exporting Data

  1. #1
    Join Date
    Nov 2004
    Location
    Anchorage
    Posts
    12

    Unanswered: Exporting Data

    Hello everybody,

    I was wondering if there is a way to export and recode data at the same time with SQL.

    For example I have gender information coded as 1 or 2 in my table and I need to upload the information to a different application that needs M or F. Is there a way to export to a new table and recode at the same time ?

    I'm still pretty new to it.

    Thank you.

    -Seb

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Data Transformation Services (DTS) and choose the use a query to specify the data transfer and then use a CASE statement (CASE WHEN field = 1 THEN "M" ELSE "F" END).

    Easy peasy.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd use something like:
    Code:
    SELECT
       CASE
          WHEN 1 = gender THEN 'F'
          WHEN 2 = gender THEN 'M'
          ELSE '?'
       END AS morf
       FROM myTable
    -PatP

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Or if you are more old-school, you can use bcp with the queryout functionality. For less bulky command line commands, you can create a view in SQL server of the query you want, then export the view.

    But then, is there really that good a market for skinned cats?

  5. #5
    Join Date
    Nov 2004
    Location
    Anchorage
    Posts
    12
    Thank you guys that helps a lot. -Seb

  6. #6
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by MCrowley
    But then, is there really that good a market for skinned cats?
    There's more ways to skin a cat than there are cats... But that's no reason to stop trying to find new ways!

    -PatP

Posting Permissions

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