Data conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • James Hamel
    New Member
    • Sep 2011
    • 2

    Data conversion

    I have a series of excel sheets from which i am converting data into our SQL 2008 database. Some of the fields in the excel files provided by the customer contain fields that are varchar(3). One example is that these describe "skin tone", and include abbreviations such as "DRK", "PAL", "RUD", etc. in our database, these fields are bit fields, with one for each description. I am assuming that, in order to convert these, a case expression needs to be composed, but i am unclear as to the syntax to be used in this situation. Any help is appreciated.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Yes, you would need a case statement for each bit field you want to set. However, the current design is poor. It really should be set up the way the excel spreadsheet is set up, it makes for easier querying.

    Comment

    • James Hamel
      New Member
      • Sep 2011
      • 2

      #3
      so my question is really this....what would that case expression actually look like?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        If you choose not to normalize the data, then one of the case statements would look like this
        Code:
        CASE WHEN fieldName = 'BLK' THEN 1 ELSE 0 END

        Comment

        Working...