June 15, 2004 at 10:22 am
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
June 16, 2004 at 4:57 am
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.
June 16, 2004 at 5:09 am
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.
June 16, 2004 at 7:56 am
Glad to have helped in some way.
June 16, 2004 at 8:38 am
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