如何获得字段的类型?
如何获得字段的类型?
------解决方案--------------------在企业管理—选择表—设计表(就行了)
------解决方案--------------------syscolumns.xtype
------解决方案--------------------SELECT 字段名=LTRIM(NAME),
类型=CASE WHEN xtype=34 THEN 'image '
WHEN xtype=35 THEN 'text '
WHEN xtype=36 THEN 'uniqueidentifier '
WHEN xtype=48 THEN 'tinyint '
WHEN xtype=52 THEN 'smallint '
WHEN xtype=56 THEN 'int '
WHEN xtype=58 THEN 'smalldatetime '
WHEN xtype=59 THEN 'real '
WHEN xtype=60 THEN 'money '
WHEN xtype=61 THEN 'datetime '
WHEN xtype=62 THEN 'float '
WHEN xtype=98 THEN 'sql_variant '
WHEN xtype=99 THEN 'ntext '
WHEN xtype=104 THEN 'bit '
WHEN xtype=106 THEN 'decimal '
WHEN xtype=108 THEN 'numeric '
WHEN xtype=122 THEN 'smallmoney '
WHEN xtype=127 THEN 'bigint '
WHEN xtype=165 THEN 'varbinary '
WHEN xtype=167 THEN 'varchar '+ '( '+LTRIM(length)+ ') '
WHEN xtype=173 THEN 'binary '
WHEN xtype=175 THEN 'char '+ '( '+LTRIM(length)+ ') '
WHEN xtype=189 THEN 'timestamp '
WHEN xtype=231 THEN 'nvarchar '+ '( '+LTRIM(length)+ ') '
WHEN xtype=239 THEN 'nchar '+ '( '+LTRIM(length)+ ') '
WHEN xtype=241 THEN 'xml '
WHEN xtype=231 THEN 'sysname ' END
FROM
(
SELECT NAME,CDEFAULT,A.ID,XTYPE,LENGTH,COLORDER
FROM SYSCOLUMNS A
WHERE A.ID=OBJECT_ID( 'tb ')
AND COLUMNPROPERTY(A.ID,A.NAME, 'IsIdentity ') <> 1
)TB
ORDER BY COLORDER