Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Posts
    5

    Unanswered: transact sql creating xml

    Is there a way to select the data and the data type for each column of a given table. I'm trying to create something along the lines of:

    <Table>STS01
    <Column data="fred" type="char">col1</Column>
    <Column data="48" type="int">col2</Column>
    <Column data="bill" type="char">col3</Column>
    </Table>

    Thanks

    Segs

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    Probably not the cleanest way but...

    Code:
    --------------------------------------------------------------------------------------------------
    select distinct sc.name, st.name,'col' + cast(sc.colorder as varchar(25))
    From syscolumns sc
    join systypes st on sc.usertype = st.usertype
    join sysobjects so on sc.id = so.id
    where so.name = '<Your Table Name>'
    and so.type = 'U'
    order by 3
    --------------------------------------------------------------------------------------------------
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Jul 2002
    Posts
    5
    Thanks but I also need the data for each column. In my example the data for col1 is fred, col2 is 48

Posting Permissions

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