Saturday, February 23, 2008

SQL-Server : To view the Column Name,type,size in the Table

To view the Columns in the table called "Activity"
-----------------------------------------------------
Type: 1
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Activity'

Type: 2
select fname=col.name, dtype=type.name, col.length, col.status from syscolumns col
inner join sysobjects obj
on col.id = obj.id
inner join systypes type
on col.xtype = type.xtype
where obj.name= 'Activity'
and type.xtype = type.xusertype order by colid



To Get the total number of Columns in the Table:
---------------------------------------------------
SELECT Count(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Activity'

No comments: