how can I list table fileds and examples of data stored within them

  • I need to document a database

    the data that has been identified as being required is as follows

    TableName,FieldName, ExampleContent

    Employees, Surname, Smith / Brown

    Employees, FirstName, John / Mary

    Stores, StoreName, London / New York

    Stores, Country, UK / USA

    etc all tables - all fields

    Getting the table and field names is fairly straight forward using systable info but how is it possible to capture actual data and transpose it into the above format?

    TIA

     

  • You need to create a cursor (@curTableName) and bring in each tablename into it using:

    SELECT TABLE_NAME

    FROM INFORMATION_SCHEMA.TABLES

    Then inside the cursor:

    Select Top 10 * from ''' + @curTableName '''

    Run this printing results to text and you can play around with the output. If you need help with the cursor, let me know and I can help you out.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Thanks, not quite what I'm after but it has prompted some lateral thinking. If I can create a table with all tables and fields I can use those values in a cursor and put them into a select statement to return say the first row then append that value to an additional column in the table / field list.

  • Glad to have helped in some way.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Might want to use DMO with VBScript or a full application to get the data like you need it. Wasn't exactly sure I understood your information above thou. Was that example info or something else?

Viewing 5 posts - 1 through 4 (of 4 total)

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