如何提取表的结构?
比如一个表,表名是Table
里面包含的字段是: 1 ID int
2 UserName varchar
3 Password varchar
4 dataTime datetime
想用SQL语句表上述的内容给显示出来,该如何写?
------解决方案--------------------SELECT c.name as FieldName,
t.name as FieldType,
c.length as FieldLength
FROM SYSCOLUMNS c
inner join systypes t on c.xusertype=t.xusertype
WHERE c.ID = OBJECT_ID( 'task ')--task为表名
------解决方案--------------------select c.name, t1.name c.length from sysobjects t, syscolumns c , systypes t1
where t.id = c.id and and c.xtype=t1.xtype and t.name = 'tablename '
------解决方案--------------------这是简单的SQL语句的运用啊。