旧系统代码CV多了想解放一下双手写个代码生成器,这时候就需要获取到表的某一些信息了
SELECT a.NAME AS colname,CONCAT(UPPER(SUBSTRING(b.name, 1, 1)), LOWER(SUBSTRING(b.name, 2,LEN(b.name)-1))) AS typename,a.length AS length,a.scale AS scale, a.prec AS prec, c.name,isnull(f.[value],'') as remark
FROM syscolumns a
inner join systypes b on a.xusertype = b.xusertype
inner join sysobjects c on a.id = c.id
inner join
sys.columns d on d.name=a.name
inner join
sys.objects e on d.object_id=e.object_id and e.Type='U'
left join
sys.extended_properties f on f.major_id=e.object_id and f.minor_id=d.Column_id and f.class=1
where c.name = 'tableName' and e.name='tableName'
order by a.colorder asc