Show Changes Show Changes
Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Administration Page Administration Page
Search

History

1/10/2007 2:23:22 AM
-85.40.207.132
10/14/2005 7:32:34 AM
-208.178.192.31
10/14/2005 7:31:33 AM
-208.178.192.31
10/14/2005 7:31:24 AM
-208.178.192.31
10/14/2005 7:31:07 AM
-208.178.192.31
List all versions List all versions

RSS feed for the FlexWiki namespace

Sql To Generate Table Details Wiki
.
Summary
 --Andrew D. Smith 
 declare @tbname varchar(200)
 select @tbname = 'inventory'


 drop table #toWiki
 select convert(varchar(255),'||{T^!C4TW80^}' + @tbname + '||') as txt, -2 as odr  into #toWiki


 insert into #toWiki VALUES('||{!}Column||{!}Allow Nulls||{!}Type||{!}Description||',-1)


 insert into #toWiki
  SELECT '||[' + C.COLUMN_NAME  + ']||'+ 
  C.IS_NULLABLE  + '||[' + C.DATA_TYPE + ']||' + 
  convert(varchar(10), COALESCE (CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION ))
  +  '|| ||',C.ORDINAL_POSITION 
  FROM INFORMATION_SCHEMA.Tables T JOIN INFORMATION_SCHEMA.Columns C
  ON T.TABLE_NAME = C.TABLE_NAME
  WHERE T.TABLE_NAME NOT LIKE 'sys%'
  AND T.TABLE_NAME <> 'dtproperties'
  AND T.TABLE_SCHEMA <> 'INFORMATION_SCHEMA'
  and t.table_name=@tbname0


 select txt from #toWiki order by odr

See Inventory for an example

If you are working with Microsoft SqlServer 2000 you can recover the description stored in the column property with this script

 --Andrew D. Smith 
 declare @tbname varchar(200)
 select @tbname = 'CG_00_SCADENZE'


 drop table #toWiki
 select convert(varchar(255),'||{T^!C4TW80^}' + @tbname + '||') as txt, -2 as odr  into #toWiki


 insert into #toWiki VALUES('||{!}Column||{!}Allow Nulls||{!}Type||{!}Description||',-1)


 insert into #toWiki
  SELECT '||[' + 
    C.COLUMN_NAME  + ']||'+ 
    C.IS_NULLABLE  + '||[' + 
    C.DATA_TYPE + ']||' + 
    convert(varchar(10), COALESCE (CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION ))+  '||' +
    convert(varchar(100), ExtP.Value) + '||'
    ,C.ORDINAL_POSITION 
  FROM INFORMATION_SCHEMA.Tables T INNER JOIN 
        INFORMATION_SCHEMA.Columns C  ON T.TABLE_NAME = C.TABLE_NAME INNER JOIN
        ::fn_listextendedproperty ('MS_Description', 'user', 'dbo', 'table', @tbname, 'column', default) ExtP ON
        C.COLUMN_NAME = ExtP.objname
  WHERE T.TABLE_NAME NOT LIKE 'sys%'
  AND T.TABLE_NAME <> 'dtproperties'
  AND T.TABLE_SCHEMA <> 'INFORMATION_SCHEMA'
  and t.table_name=@tbname
 select txt from #toWiki order by odr
See

Original Contribution by AndrewDSmith

Not logged in. Log in

Welcome to the home of FlexWiki, a collaboration tool, based on WikiWiki, implemented using Microsoft .NET technologies

This is FlexWiki, an open source wiki engine.

This site supports the new NoFollow anti-spam initiative.
Change Style

Recent Topics