SQL Server生成实体
Posted 风吹一点云
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL Server生成实体相关的知识,希望对你有一定的参考价值。
SELECT ‘/// <summary> /// ‘ + CAST(C.value AS NVARCHAR) + ‘ /// </summary> [DataMember] public string ‘ + CAST(B.name AS VARCHAR) + ‘ {get;set;}‘+CHAR(13) AS 属性 , ROW_NUMBER() OVER ( ORDER BY B.name ) AS rnum INTO #temp710 FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id WHERE A.name = ‘表名‘; DECLARE @i INT = 1; DECLARE @count INT = 42; DECLARE @tempColumn NVARCHAR(500) = ‘‘; WHILE ( @i <= @count ) BEGIN SELECT @tempColumn = 属性 FROM #temp710 AS t WHERE t.rnum = @i; PRINT @tempColumn; SET @i = @i + 1; END; DROP TABLE #temp710;
以上是关于SQL Server生成实体的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Microsoft SQL Server Management Studio 生成数据库的实体关系 (ER) 图?