小煎的IT筆記本: SQL Server 找出所有資料表, 欄位, 欄位型態.
SQL Server 找出所有資料表, 欄位, 欄位型態.
SELECT dbo.sysobjects.name AS sTableName,
dbo.syscolumns.name AS sColumnsName,
dbo.syscolumns.prec AS iColumnsLength,
dbo.syscolumns.colorder AS iColumnsOrder,
dbo.systypes.name + " AS sColumnsType,
dbo.syscolumns.isnullable AS iIsNull
FROM dbo.sysobjects INNER JOIN
dbo.syscolumns ON dbo.sysobjects.id = dbo.syscolumns.id INNER JOIN
dbo.systypes ON dbo.syscolumns.xusertype = dbo.systypes.xusertype
WHERE (dbo.sysobjects.xtype = ‘U’)
and (dbo.systypes.name+" IN (‘varchar’, ‘char’) )