本代码适用于: SQLSERVER2000/2005
SQL语句如下:
select c.name, t.name as type, c.length
,(case t.name
when 'nvarchar' then c.length/2
when 'nchar' then c.length/2
else c.length
end)
as reallength
from syscolumns c join systypes t
on c.xtype=t.xtype
where t.name <> 'sysname' and c.id=object_id('Table1')
-- 加了这句代码,可以使列按设计时的顺序输出
order by colorder ASC
为了方便使用,可将其封装成一个函数代码如下:



























这是一个运行结果:
[C++]Linux之头文件sys/types.h[/usr/include/sys]
[C++]Linux之文件拷贝在系统调用和C库函数下的效率比较
Linux之Ubuntu下安装屏幕录像软件(SimpleScreenRecorder)【摘抄】
[C++]基于Curses库的实时系统监测可视化系统-2017-12-09 15-07-42
[C++]Linux之虚拟文件系统[/proc]中关于CPU/内存/网络/内核等的一些概要性说明
[C++]Linux之计算内存利用率与辨析
[C++]Linux之网络实时检测功能
[C++]Linux之C编程异常[true未定义解决方案]
[C++]Linux之读取计算机网络数据[/proc/net/dev]