Today, I'm going to tidy up a few databases, form a table structure document, convenient for later maintenance use.
Find a script on the internet is good, small changes to meet my requirements, execute the SQL script.
In the result can see the structure of all the database tables, this time as long as the full selection, and then right-click the property box, choose to save the results as, this time you just choose to export the CSV, and then create a new Excel table, select the data in the menu bar, and then choose from the text, the following people can self-processing.
SQL Server script:
SELECT Table name = case if A.colorder=1 then D.name Else ' End, table description = case when a.colorder=1 then IsNull (f.v Alue, ') Else ' End, field ordinal = a.colorder, field name = a.name, field description = IsNull (G.[value], '), identity = Cas e when ColumnProperty (A.id,a.name, ' isidentity ') =1 Then ' √ ' Else ' End, primary key = case when exists (SELECT 1 from Syso bjects where xtype= ' PK ' and Parent_obj=a.id and name in (SELECT name from sysindexes Where indid in ( SELECT indid from Sysindexkeys WHERE id = a.id and colid=a.colid)) Then ' √ ' Else ' end, type = b.name, consume bytes Number = a.length, length = ColumnProperty (a.id,a.name, ' PRECISION '), number of decimal digits = IsNull (ColumnProperty (a.id,a.name, ' Scal E '), 0), allow null = case time a.isnullable=1 Then ' √ ' Else ' End, default value = IsNull (E.text, ') from syscolumns A Left joins Systypes B on A.xusertype=b.xusertype Inner joins sysobjects D on a.id=d.id and d.xtype= ' U ' and D.name<> ' DtproperTies ' left join syscomments E on a.cdefault=e.id left join Sys.extended_properties G on a.id=g.major_id and A . colid=g.minor_id left Join sys.extended_properties F on d.id=f.major_id and f.minor_id=0--where d.name= ' OrderInf O '--if only the specified table is queried, add this condition to Order by A.id,a.colorder
SQL Server Export table structure