Tuesday, July 19, 2011

To find column_name,Type,Length in a Table

select  sst.name,c.name,st.name as datatype, c.max_length  datatype_size
from sys.columns c
inner join sys.types st
on c.user_type_id=st.user_type_id
inner join sys.tables sst
on c.object_id = sst.object_id
where sst.type = 'u'and  c.object_id=object_id('emp')

No comments:

Post a Comment