Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieve Column Info
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01313335
Message ID:
01313336
Views:
8
The Column Size, Precision, Null/Not Null is in sys.colums
SELECT t.name AS TableNAme, c.name AS ColName, c.column_id AS Sequence,
		c.max_length, c.precision, c.scale, c.is_nullable,
		ep.value	
	FROM sys.tables t
	JOIN sys.columns c
		ON c.object_id = t.object_id
	LEGT JOIN sys.extended_properties ep
		ON ep.major_id = t.object_id
			AND ep.minor_id = c.column_id
>I want to return info about a SQL 2005 dtabases's tables.
>
>This code returns the a table who's columns are TableName, ColumnName, ColumnDesc and Sequence. What do
>I need to add to get Column Size, Precision, Null/Not Null, PK info, ect?
>
>
>
>SELECT      o.Name AS ObjectName,
>            c.name AS ColumnName,
>            ep.value AS ColumnDesc,
>            c.colid AS Sequence
>FROM        sys.objects o INNER JOIN sys.extended_properties ep
>            ON o.object_id = ep.major_id
>            INNER JOIN sys.schemas s
>            ON o.schema_id = s.schema_id
>            LEFT JOIN syscolumns c
>            ON ep.minor_id = c.colid
>            AND ep.major_id = c.id
>WHERE       o.type = 'U'
>ORDER BY    ObjectName, Sequence
>
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform