我怎样才能得到" REAL"来自sql server查看查询的列/表名称

时间:2015-02-25 14:24:56

标签: sql-server-2008 sql-view information-schema

我正在尝试编写一个查询来检索“真实”列名,因为它们是由表定义定义的,但是通过它们使用的视图。

Find the complete document with all the queries and screen dumps of the results I'am looking for

1 个答案:

答案 0 :(得分:0)

查看列并不总是映射到表列。考虑以下(组成)视图定义。

CREATE VIEW MadeUp
AS    
SELECT 
    GETDATE() AS CurrDate,
    0 AS Zero,
    object_id + schema_id AS SumId,
    name + type_desc COLLATE SQL_Latin1_General_CP1_CI_AS AS SomeString,
    ( SELECT COUNT(*) FROM sys.tables ) AS NumTables    
FROM sys.objects;

您最好的选择可能是手动检查您的视图定义以确定您需要的内容。