Get table and column in sql server

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)=’salary_table_detail’

ORDER BY c.OBJECT_ID;

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)=’salary_table_detail’
ORDER BY c.OBJECT_ID;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s