Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
revive
Starting Member
3 Posts |
Posted - 2006-11-16 : 19:13:09
|
| Hi,1. I am wondering if exist a tool to let me easily document my databases, unde MSQL. e.g.I want to create a doc file or better a html file with all my databases objects, descriptions, DDLs etc...2. Another tool to create code patterns; I need a something that generate custom code patterns, but in VBScript or C#.p.s. Sorry if i created this topic on another forum.Thanks,<u><b>Jack Bower</b></u>software developerIATAR Studiohttp://iatar.port5.com |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-11-16 : 21:41:29
|
For documenting databases, I am partial to sqlspec, but then I wrote it, so I am biased. link to it is in my sig below if you want to check it out. There's a review here: http://www.sql-server-performance.com/software_spotlights/da_sqlspec.asp SqlSpec - a fast, cheap, and comprehensive data dictionary generator forSQL Server 2000/2005 and Analysis Server 2005 - http://www.elsasoft.org |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-11-17 : 08:39:24
|
| +1 to SQLSpec. I do the vast majority of my documentation in extended properties. SQLSpec sources those extended properties for the docs and puts together a very nice dictionary in both .CHM and HTML. The major benefit to me with keeping the metadata in the database is that I can generate a new set of documentation any time. In fact, I could (an am considering) generating the docs as part of my nightly data load. That way any object added will automatically make it into the docs. I recommend you check out Jesse's site.For patterns, aside from the typical P&P (patterns and practices) documentation, I am big into templates. I have a template for everything and it ensure that I get standardized comments into my procs and a standardized look an feel. Many of my templates have use sql-from-sql code so that I use the template to fill in some basic info and some parameters in my sql-from-sql and then I execute my sql-from-sql to generate even more standardized code. I could give an example, if need be. This process works well for me an my team.Jay White |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-11-17 : 09:11:44
|
| "sql-from-sql"(that phrase adopted, Ta!) |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-11-17 : 09:24:23
|
| I picked that up for the Oracle guy that first showed me a databbase way back when. I've never found a better term ... I'm open to one 'cause every time I say it, people look at me funny. I use sql-from-sql all the time ... I've even used sql-from-sql-from-sql once or twice :)Jay White |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-17 : 11:24:02
|
quote: I could give an example, if need be.
I'd like to see the example if you're offering - always ready to see how someone else does it. |
 |
|
|
darkness
Starting Member
3 Posts |
Posted - 2006-11-17 : 11:25:12
|
| Hi guys,Some weeks ago, I found a cool software report base application, that it is a cool toy.I can document my database under sql2005 server. I don't knwo if it works for 2000 too, but it is easy to use, so far.I sow that it has some nice features. I downloaded from here: http://www.apexsql.com/downloads.asp#docFor me it is helpfully. I like it more than SQLSpec.David Palmer SQL Manager |
 |
|
|
revive
Starting Member
3 Posts |
Posted - 2006-11-17 : 11:31:37
|
| Hi guys,Thanks for you responses. I will download them both.I want just a simple database documentation, nothing complex and easy to use.Darkness: you link is going here... :)Thanks again.Jack Bowersoftware developerIATAR Studiohttp://iatar.port5.com |
 |
|
|
darkness
Starting Member
3 Posts |
Posted - 2006-11-17 : 11:33:59
|
| sorry i had somethign else in clipboard. I re-edited it.David Palmer SQL Manager |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-11-17 : 12:46:53
|
What follows is purely for example purposes ... obviously, you cannot repurpose this directly as it is highly customized for my environment.use <Database, sysname, MyDatabase>goif exists ( select * from sys.objects where object_id = object_id(N'Student.Fact<TableName, sysname, SampleTable>') and type in (N'U')) drop table Student.Fact<TableName, sysname, SampleTable>gocreate table Student.Fact<TableName, sysname, SampleTable> ( <TableName, sysname, SampleTable>ID int identity (1,1) not null, SourceKey int not null, DimensionID int not null, EventID int not null constraint df_Fact<TableName, sysname, SampleTable>_EventID default (0), constraint pk_Fact<TableName, sysname, SampleTable> primary key clustered (<TableName, sysname, SampleTable>ID), constraint uq_Fact<TableName, sysname, SampleTable>_SourceKey unique nonclustered (SourceKey), constraint fk_Fact<TableName, sysname, SampleTable>_Dimension foreign key (DimensionID) references Student.Dimension)goexec HEA.UpdateDictionary @Value = 'Table for the <TableName, sysname, SampleTable> fact. This table is loaded by HEA.LoadFact<TableName, sysname, SampleTable>.', @Level0Object = 'Student', @Level1Object = 'Fact<TableName, sysname, SampleTable>'go/******<DELETE ME>*******/select 'exec HEA.UpdateDictionary @Value = ''' + case when vd.Value is not null then replace(convert(varchar(8000), vd.Value),'''', '''''') when sc.name = '<TableName, sysname, SampleTable>ID' and dp.Name = 'MS_Description' then 'Surrogate key from My Database' else '' end + ''', @Level2Object = ''' + sc.name + ''', @Name = ''' + dp.Name + ''', @Level0Object = ''Student'', @Level1Object = ''Fact<TableName, sysname, SampleTable>'''from HEA.DictionaryProperty dp inner join ( sys.columns sc inner join sys.objects so on sc.object_id = so.object_id inner join sys.schemas ss on so.schema_id = ss.schema_id left join HEA.ViewDictionary vd on vd.Level0Name = 'Stage' and vd.Level1Name = 'Fact<TableName, sysname, SampleTable>' and vd.Level2Name = sc.Name) on (vd.Name is not null and vd.Name = dp.Name) or (vd.Name is null)where so.name = 'Fact<TableName, sysname, SampleTable>' and ss.name = 'Student' and not (sc.Name = '<TableName, sysname, SampleTable>ID' and dp.Name = 'Source')order by dp.Name desc, sc.Column_id/*****</DELETE ME>*******/goexec HEA.UpdateDictionary @Name = 'MS_Description', @Value = 'Default constriant on Student.Fact<TableName, sysname, SampleTable>(EventID) = 0', @Level0Object = 'Student', @Level1Object = 'Fact<TableName, sysname, SampleTable>', @Level2Object = 'df_Fact<TableName, sysname, SampleTable>_EventID'exec HEA.UpdateDictionary @Name = 'MS_Description', @Value = 'Clustered Primary Key on Student.Fact<TableName, sysname, SampleTable>(<TableName, sysname, SampleTable>ID)', @Level0Object = 'Student', @Level1Object = 'Fact<TableName, sysname, SampleTable>', @Level2Object = 'pk_Fact<TableName, sysname, SampleTable>'exec HEA.UpdateDictionary @Name = 'MS_Description', @Value = 'Nonclustered unique constraint on Student.Fact<TableName, sysname, SampleTable>(SourceKey)', @Level0Object = 'Student', @Level1Object = 'Fact<TableName, sysname, SampleTable>', @Level2Object = 'uq_Fact<TableName, sysname, SampleTable>_SourceKey', @SyncDictionary = 1go OK, so this template is what I use to create a script file to create a Fact table in my Dimensional Model. We have a naming convention (I'm not a big fan) of prefacing the fact table names with 'Fact'.So when I create a file from this template, the first thing I do is Ctrl-Shift-M to bring up my properties window and I fill in the Database and the TableName. Once that is done, I add the Dimension columns (DimensionID is there for example purpose only) and my measures. I am sure to set up my DRI correctly with the FK constraints. When that is all set, I exec the first half of the template to create my Fact table.The second half of the template is to update my data dictionary. The dictionary is sync'ed with my extended properties (I have two ... I use the MS_Description and a custom "Source" property). You'll notice the last call to updatedictionary passes @SyncDictionary and this instructs to proc to sync these new dictionary values with the extended props.In between the Delete Me tags is some sql-from-sql that will generate the calls to UpdateDictionary for each of the columns I just created. I run this (output to text) and copy that back in place of the everything inbetween (and including) the Delete Me comments. Then I fill in all my dictionary values and run the set of UpdateDictionary proc calls.EDIT: On reread, I realized that my sql-from-sql actually looks at the objects already in my dictionary, but for the 'Stage' schema. Since my stage and student schema versions of this table generally match, I can run the sql-from-sql prior to actually creating the table. For this example, I guess, it really is neither here nor there ... Jay White |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-11-17 : 12:53:12
|
| sorry about the width ... I usually try to keep all my scripts to 80 columns ....Jay White |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-17 : 13:06:57
|
| Thanks for sharing with us Jay! |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-11-17 : 14:35:02
|
| " sql-from-sql-from-sql "That's a lot of doubled-up-single-quotes! |
 |
|
|
|
|
|
|
|