因为项目数据库中三张表需要合并指定的字段,所以在SQL Server -》工具-》SQL查询分析器里执行三表联合查询,需要把得到的查询结果导出,导出的CSV,但不能显示出三张表合并后的字段的名称。
Java学习网整理:
使用下面代码很方便得到数据库中表的字段名称。
select
c.name as 'colname'
,t.name 'coltype'
,c.length 'collength'
,c.prec as 'colprec'
,c.isnullable 'colisnull'
,m.text 'defaultval'
from syscolumns c
inner join systypes t on c.xusertype=t.xusertype
left join syscomments m on c.cdefault=m.id
where objectproperty(c.id,'IsUserTable')=1 and object_name(c.id)='数据库表名称'