.net 筆記

學習.net
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

sql 讀取數據庫表 字段 屬性

Posted on 2007-10-16 11:27  陳偉  阅读(272)  评论(0)    收藏  举报
select
--temp=(select count(*) from syscolumns
--           where object_id('EB_Admin_UserInCategory')=id
--            and colid<=A.colid),
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=251 THEN 'sysname' END
--  +','+CHAR(10)
,length,isnullable  from syscolumns A
where object_id('EB_Price_QuoteOrderDetail')=id
order by colid