1

假设这个视图:

SELECT
 [Pr].[Id],
 [Pr].[Title],
 [Pr].[Category_Id] AS [CategoryId],
 [Pr].[IsScanAllowed],
 [Pr].[MaxLevelOfRegistration],
 [Cat].[Title] AS [Category],
 [Cat].[MajorCategory_Id] AS [MajorCategoryId],
 [Mc].[Title] AS [MajorCategory]
 [Cat].[Title]+[Pr].[Title] AS [FullProduct]
FROM [Products].[Product] AS [Pr]
INNER JOIN [Products].[Category] AS [Cat] ON [Pr].[Category_Id] = [Cat].[Id]
INNER JOIN [Products].[MajorCategory] AS [Mc] ON [Cat].[MajorCategory_Id] = [Mc].[Id];

那么有没有办法找到这个视图的每个列的基列,除了[FullProduct]这是一个计算列,所有其他列都有一个基列。像这样的东西:BaseOf(MajorCategoryId) is [Products].[MajorCategory].[Id]我尝试使用Microsoft.SqlServer.Management.Smo但我找不到任何东西,有人对此有任何想法吗?

4

1 回答 1

1

没有办法知道,因为它没有传递回客户端,但您可以构造列名来显示它——像这样:

SELECT
 [Pr].[Id] AS [Products_Id],
 [Pr].[Title] AS [Products_Title],
 [Pr].[Category_Id] AS [Products_CategoryId],
 [Pr].[IsScanAllowed] AS [Products_IsScanAllowed],
 [Pr].[MaxLevelOfRegistration] [Products_MaxLevelOfRegistration],
 [Cat].[Title] AS [Category_Title],
 [Cat].[MajorCategory_Id] AS [Category_MajorCategoryId],
 [Mc].[Title] AS [MajorCategory_Title]
 [Cat].[Title]+[Pr].[Title] AS [FullProduct]
FROM [Products].[Product] AS [Pr]
INNER JOIN [Products].[Category] AS [Cat] ON [Pr].[Category_Id] = [Cat].[Id]
INNER JOIN [Products].[MajorCategory] AS [Mc] ON [Cat].[MajorCategory_Id] = [Mc].[Id];

然后要查看表格,您可以将第一项在拆分上_


您还可以使用 SQL 元数据下载视图源并对​​其进行解析,但这对我来说似乎需要做很多工作。

于 2012-07-15T13:59:13.957 回答