生成数据字典
select 'CE' as 数据库
, d.name as 表名
, f.value as 表说明
, a.colorder as 字段序号
, a.name as 字段名
, case when b.name='text' then b.name
when coalesce(columnproperty(a.id,a.name,'Scale'),0)=0 then
b.name+'('+convert(varchar(20),columnproperty(a.id,a.name,'PRECISION'))+')'
else b.name+'('+convert(varchar(20),columnproperty(a.id,a.name,'PRECISION'))+','
+convert(varchar(20),coalesce(columnproperty(a.id,a.name,'Scale'),0))+')' end 类型
, case when a.isnullable=1 then '' else 'Y' end as 不允许空
, e.text as 默认值
, case when exists(select 1 from sysobjects where xtype='PK' and name in (
select name from sysindexes where indid in(
select indid from sysindexkeys where id = a.id and colid=a.colid
)
)) then 'PRI' else '' end as 键值
, g.value as 字段说明
from syscolumns a
left join systypes b on a.xtype=b.xusertype
join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties'
left join syscomments e on a.cdefault=e.id
left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id
left join sys.extended_properties f on d.id=f.major_id and f.minor_id =0
order by d.name,a.colorder
;
日期格式化函数
select convert(varchar(100), getdate(), 0)
select convert(varchar(100), getdate(), 1)
select convert(varchar(100), getdate(), 2)
select convert(varchar(100), getdate(), 3)
select convert(varchar(100), getdate(), 4)
select convert(varchar(100), getdate(), 5)
select convert(varchar(100), getdate(), 6)
select convert(varchar(100), getdate(), 7)
select convert(varchar(100), getdate(), 8)
select convert(varchar(100), getdate(), 9)
select convert(varchar(100), getdate(), 10)
select convert(varchar(100), getdate(), 11)
select convert(varchar(100), getdate(), 12)
select convert(varchar(100), getdate(), 13)
select convert(varchar(100), getdate(), 14)
select convert(varchar(100), getdate(), 20)
select convert(varchar(100), getdate(), 21)
select convert(varchar(100), getdate(), 22)
select convert(varchar(100), getdate(), 23)
select convert(varchar(100), getdate(), 24)
select convert(varchar(100), getdate(), 25)
select convert(varchar(100), getdate(), 100)
select convert(varchar(100), getdate(), 101)
select convert(varchar(100), getdate(), 102)
select convert(varchar(100), getdate(), 103)
select convert(varchar(100), getdate(), 104)
select convert(varchar(100), getdate(), 105)
select convert(varchar(100), getdate(), 106)
select convert(varchar(100), getdate(), 107)
select convert(varchar(100), getdate(), 108)
select convert(varchar(100), getdate(), 109)
select convert(varchar(100), getdate(), 110)
select convert(varchar(100), getdate(), 111)
select convert(varchar(100), getdate(), 112)
select convert(varchar(100), getdate(), 113)
select convert(varchar(100), getdate(), 114)
select convert(varchar(100), getdate(), 120)
select convert(varchar(100), getdate(), 121)
select convert(varchar(100), getdate(), 126)
select convert(varchar(100), getdate(), 130)
select convert(varchar(100), getdate(), 131)