November 3, 2008 at 3:31 pm
My boss asked me to create a document containing all the tables and all the fields within the tables and their datatypes in a database.There more thn 50 tables so it is inefficient to look up each table individually.I am sure there must be some way this can be done.
Can any of you SQL GURU's help me with this sticky problem.
thanks
November 3, 2008 at 3:45 pm
i got what you are looking for;
there was a script submission that someone made; It creates an HTML document, which you just save and view.
I've enhanced it slightly, and you can download it here:
http://www.stormrage.com/blogpix/db_documentation_in_html_script_enhanced.txt
Lowell
November 3, 2008 at 3:47 pm
Here is a starting point: BOL (Books On-Line).
Lookup the following:
sys.databases
sys.tables
sys.columns
sys.types
November 3, 2008 at 3:52 pm
just realized that script does not handle things like varchar(max) gracefully.
here is a link to a 2005 version:
db_documentation_in_html_script_enhanced2005.txt
Lowell
November 3, 2008 at 3:54 pm
Lowell, thank you for your quick reply.
Unfortunately I cannot open up the script you attached .Can you paste the entire code in the post.
thanks
November 3, 2008 at 3:56 pm
check the first link again, I re-edited it; the second link should be fine as well. they just open as a text file; the script is beyond the size limit for possting; it's thousands of lines.
Lowell
November 3, 2008 at 4:01 pm
Lowell,Thank you very much.I got what i was looking for and more.:D
November 3, 2008 at 6:43 pm
Hello,
Just look at this, if this make more sense ....
SELECT A.name 'TableName', B.name 'ColumnName', C.name + ' ( '+
CASE WHEN B.length = -1 THEN 'MAX' ELSE CONVERT(VARCHAR(10), B.length) END + ' )' 'DataType'
FROM sysobjects A, syscolumns B, systypes C
WHERE A.name = OBJECT_NAME(B.id) and B.xtype = c.xtype and A.xtype = 'u'
Hope it helps,
Imran.
November 4, 2008 at 8:17 am
Thank you Imran.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply