October 29, 2011 at 5:36 pm
Hi all,
trying to learn tsql so thought i would try and make a data dictionary for my class in db design from tsql instead of manually in excel!
The end result should look like:
Table | Column | Type | Size | Constraints | PK | FK | Defaults
Using sys.objects sys.columns and sys.types it looks like i can get everything i need.. but I cant work out how to do it..
What im thinking i need to do is:
Check if there's a parent_object_id
If there is see What the type_desc is
If its PK then boolean the PK table
If its F then boolean the FK table
On the row that's on the parent_object_id
If anyone has any simple examples of how to work it out .. that would be great...
I keep getting simple bits done.. but cant see how to put it all together ๐ (join the col table to the types to get the format for the cols)
Thanks for any ideas, snippets, help :)..
S
October 29, 2011 at 6:45 pm
look at this link - might not be exactly what you want, but a good place for yout to start
http://www.sqlservercentral.com/scripts/Data+Dictionary/72048/
by Abdullah.Khan
October 30, 2011 at 7:16 am
Hi prvmine,
Yeah figured there would be some more pro ones out there..
Trying to use it as a learning process though so going to try and keep my eyes off that one! hehe
thanks for the link though ๐
October 30, 2011 at 7:26 am
Exactly, you can pull the example apart see how it works -- comment things out, add new elements -โall while youโre learning.
October 30, 2011 at 9:11 am
prvmine (10/29/2011)
look at this link - might not be exactly what you want, but a good place for yout to starthttp://www.sqlservercentral.com/scripts/Data+Dictionary/72048/
by Abdullah.Khan
Gosh... I wouldn't use that script as an example. Have you actually checked its results? It doesn't return the PK correctly and its a terrible example of how to format code.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply