Showing posts with label formated. Show all posts
Showing posts with label formated. Show all posts

Monday, March 12, 2012

how to get schema

Hi,

Could anyone tell me on how to get schema of a table(s) into excel or even simple well formated. text file. I tried scripts but seems complicated.

All i want is field name, datatype, size... That's it.

Thank you.

The following query will help you..

Select
T.Name TableName
,C.Name ColumnName
,Ty.name DataType
,C.Length
,C.Prec
,C.Scale
,Case When C.IsNullable =0 Then 'NULL' Else 'NOT NULL' End as Nullable
From
Sysobjects T
Join Syscolumns C on T.id = C.Id
Join systypes Ty On C.xtype = Ty.xType
Where
T.Type='U'
Order By
T.Name,
C.Colorder

|||I owuld prefer using the INFORMATION_SCHEMA.COLUMNS view.

Jens K. Suessmeyer.

http://www.sqlserver2005.de