找回密碼
 註冊
搜索
查看: 4346|回復: 0

查出 Table 有哪些欄位

[複製鏈接]
發表於 2010-11-12 17:31:33 | 顯示全部樓層 |閱讀模式
查詢欄位
select name from syscolumns where id=object_id('TableName')

查詢欄位、型態
SELECT OBJECT_NAME(c.OBJECT_ID) TableName,
c.name AS ColumnName,
t.name AS TypeName
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id = t.user_type_id
WHERE c.OBJECT_ID = (
SELECT id
FROM sysobjects
WHERE XTYPE = 'U' AND NAME = 'TableName'
)

Reference:
http://social.msdn.microsoft.com ... 6-8a7d-97115355ae4b
http://www.programmer-club.com.t ... sqllanguage/46.html
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|彩色筆小沛的知識庫

GMT+8, 2024-11-21 17:14 , Processed in 0.019010 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表