[MSSQL]如何找出table的column詳細資料

有關資料庫的討論, 都可以在這發表哦~~
回覆文章
頭像
tim
文章: 1379
註冊時間: 2008年 11月 26日, 00:49

[MSSQL]如何找出table的column詳細資料

文章 tim »

請使用

代碼: 選擇全部

SELECT A.colid,
      A.name as COLUMN_NAME,
      C.name as DATA_TYPE,
      A.length as DATA_LENGTH,
      case A.isnullable when 1 then 'nullable' when 0 then 'not nullable' end as ISNULLABLE,
      B.value as COLUMN_DESCRIPTION

 FROM dbo.syscolumns A
 left join dbo.sysproperties B on A.id = b.id and A.colid = B.smallid and B.name='MS_Description'
 left join dbo.systypes C on A.xtype = C.xtype
WHERE A.id = (select id
                from dbo.sysobjects
               where name = '資料表名' and type = 'U')
ORDER BY A.colid
多多留言, 整理文章, 把經驗累積下來.....
回覆文章