only My site

Saturday, May 21, 2011

MSSQL T-SQL DB Table column info



select distinct

TBL.name as TableName,

COL.Name as ColumnName, TYP.name as Type, COL.max_length as Length,

COL.precision as Precision, CASE COL.is_nullable WHEN 1 THEN 'Null' ELSE 'Not Null' end as 'Null' from sys.columns COL

inner join sys.objects TBL on COL.object_id= TBL.object_id

inner join sys.types TYP on TYP.system_type_id= COL.system_type_id

where TBL.type ='u' and TBL.name != 'sysdiagrams'

and TYP.name !='sysname' order by

TBL.name,

COL.name





select

distinct

--TBL.name as TableName,

COL.Name as ColumnName, TYP.name as Type, COL.max_length as Length,

COL.precision as Precision, CASE COL.is_nullable WHEN 1 THEN 'Null' ELSE 'Not Null' end as 'Null' from sys.columns COL

inner join sys.objects TBL on COL.object_id= TBL.object_id

inner join sys.types TYP on TYP.system_type_id= COL.system_type_id

where TBL.type ='u' and TBL.name != 'sysdiagrams'

and TYP.name !='sysname' order by

--TBL.name,

COL.name

Friday, May 6, 2011