查出 Table 有哪些欄位
查詢欄位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/Forums/zh-TW/805/thread/81fcb805-138a-4406-8a7d-97115355ae4b
http://www.programmer-club.com.tw/showSameTitleN/sqllanguage/46.html
頁:
[1]