Thursday, November 25, 2010
Query Data Type, Length and other information of table columns
--Query Data Type, Length and other information of table columns
SELECT
OBJECT_NAME(c.OBJECT_ID) TableName
,c.name AS ColumnName
,SCHEMA_NAME(t.schema_id) AS SchemaName
,t.name AS TypeName
,t.is_user_defined
,t.is_assembly_type
,c.max_length
,c.PRECISION
,c.scale
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
WHERE OBJECT_NAME(c.OBJECT_ID) = 'myTableName'
ORDER BY c.OBJECT_ID;
-- Check Table Row Size and Sort by maximum size
-- SQL Server 2000 the Maximum Row Size limit is 8060 Bytes
SELECT OBJECT_NAME (sc.[id]) tablename
, COUNT (1) nr_columns
, SUM (sc.length) maxrowlength
FROM syscolumns sc join sysobjects so on sc.[id] = so.[id]
WHERE so.xtype = 'U'
GROUP BY OBJECT_NAME (sc.[id])
ORDER BY SUM (sc.length) desc
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment