转自网络:
select '/**'+char(13)+char(10) +'*'+isnull(CONVERT(VARCHAR(100),g.value),'') + char(13)+char(10) +'*/'+char(13)+char(10) +'@TableField("'+ a.name +'")' + char(13)+char(10) +'private '+ case b.name WHEN 'bigint' then 'Long' WHEN 'int' then 'Integer' WHEN 'smallint' then 'Short' when 'varchar' then 'String' when 'nvarchar' then 'String' when 'text' then 'String' when 'decimal' then 'BigDecimal' when 'bit' then 'Boolean' when 'float' then 'BigDecimal' when 'datetime' then 'LocalDateTime' end +' '+lower(substring(a.name,1,1))+SUBSTRING(a.name,2,len(a.name)-1)--保持字段名称的原始大小写则直接用a.name +';'+char(13)+char(10) --,b.name,a.max_length ,g.value,b.name,a.name from sys.columns a LEFT join sys.types b on a.user_type_id=b.user_type_id LEFT join sys.extended_properties g on a.object_id=g.major_id and a.column_id=g.minor_id where object_id=object_id('dbo.Business') ;--其中Business为表名