Build table with field map

  • Hello All!

    I have been struggling with this for a while now and figured I'd ask. I am in the process of making a dynamic database to help improve the the workflow of a project for my company.

    They use what they call a Field map that lists fields, data types, and lengths that is distributed to vendors and customers. The customers then return us a CSV populating those fields. The problem I am having is that the fields are not literally fields, they are values in a table.

    What I need to do is "pivot" this table so that the "fieldname" value becomes columns.

    Let me illustrate:

    Source Table

    Field Name | Field Type | Field Size

    PROPCODE | Text | 20

    PROPNAME | Text | 100

    PROPADD1 | Text | 50

    PROPADD2 | Text | 50

    PROPCITY | Text | 50

    PROPSTATEPROV | Text | 2

    PROPREGION | Text | 100

    Desired Result

    PROPCODE | PROPNAME | PROPADD1 | PROPADD2 | PROPCITY | PROPSTATEPROV | PROPREGION

    I have thought about writing VB to generate an XML format file but cant figure out how to do this in SQL Server. I have also thought about using a Pivot but I cant seem to get this to work.

    Any thoughts?

  • post sample data with table definiton . see the link in my signature

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply