在SQLSERVER内如何得到一个字段的数据类型???
rt 问题点数:50、回复次数:4Top
1 楼zlp321002(Life Is Good,Let's Shine)回复于 2004-08-03 18:31:00 得分 5
select name from systypesTop
2 楼rea1gz(冒牌realgz V0.4)回复于 2004-08-03 18:31:11 得分 0
sp_columns @table_name = 'tablename',
@column_name = 'columnname'
Top
3 楼rea1gz(冒牌realgz V0.4)回复于 2004-08-03 18:33:19 得分 20
select t.name from systypes t,syscolumns c
where c.usertype=t.usertype
and c.id=object_id('tablename')
and c.name='columnname'
Top
4 楼WangZWang(先来)回复于 2004-08-03 18:35:16 得分 25
--
SELECT 表名=case when a.colorder=1 then d.name else '' end,
表描述=case when a.colorder=1 then isnull(f.value,'') else '' end,
字段序号=a.colorder,
类型=b.name,
长度=a.length,
字段名=a.name,
字段描述=isnull(g.[value],'')
FROM syscolumns a
left join systypes b on a.xtype=b.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties'
left join sysproperties g on a.id=g.id and a.colid=g.smallid
left join sysproperties f on d.id=f.id and f.smallid=0
Where d.name='要查询的表' --如果只查询指定表,加上此条件
order by a.id,a.colorderTop




