本文向大家介绍了使用SQL语句提取数据库所有表的表名、字段名的实例代码,在SQLserver 中进行了测试,具体内容如下:
--查询所有用户表所有字段的特征
SELECT D.Name as TableName, A.colorder AS ColOrder, A.name AS Name,
COLUMNPROPERTY(A.ID,A.Name, 'IsIdentity') AS IsIdentity,
CASE WHEN EXISTS
(SELECT 1
FROM dbo.sysob
MS SQL SERVER 获取当前数据库文件等信息,适用于多个版本: 代码如下:SELECT dbf.file_id AS FileID , dbf.name AS [FileName] , s.filename AS FileLocation , CAST(dbf.size/128.0 AS DECIMAL(19,2)) AS FileSizeMB , CAST(CAST(FILEPROPERTY(dbf.name, ‘SpaceUsed’) AS int)/12
1、MSSQL2000 代码如下: SELECT 表名 = case when a.colorder=1 then d.name else ” end, 表说明 = case when a.colorder=1 then isnull(f.value,”) else ” end, 字段序号 = a.colorder, 字段名 = a.name, 标识 = case when COLUMNPROPERTY( a.id,a.name,’IsIdentity’)=1 then ‘√’else ” e