在 SQL Server 2008 R2 中获取表值函数的结果列 [英] Getting the result columns of table valued functions in SQL Server 2008 R2
问题描述
对于常量生成器,我喜欢获取所有表值函数的结果列的元数据(每个表值函数返回的列的名称是什么).我怎样才能得到它们?我是否必须解析函数的源代码或是否有提供此信息的接口?
For a constants generator I like to get the meta data of result columns for all my table valued functions (what are the names of the columns returned by each table valued function). How can I get them? Do I have to parse the function's source code or is there an interface providing this information?
感谢您的帮助
克里斯
我用来获取 TVF 的以下查询:
The following query I use to get the TVFs:
SELECT udf.name AS Name, SCHEMA_NAME(udf.schema_id) AS [Schema]
FROM master.sys.databases AS dtb, sys.all_objects AS udf
WHERE dtb.name = DB_NAME()
AND (udf.type IN ('TF', 'FT'))
AND SCHEMA_NAME(udf.schema_id) <> 'sys'
推荐答案
此信息可在 sys.columns
为具有列的对象的每一列返回一行,例如视图或表格.以下是具有的对象类型列表列:
Returns a row for each column of an object that has columns, such as views or tables. The following is a list of object types that have columns:
表值汇编函数 (FT)
Table-valued assembly functions (FT)
内联表值 SQL 函数 (IF)
Inline table-valued SQL functions (IF)
内部表 (IT)
系统表 (S)
表值 SQL 函数 (TF)
Table-valued SQL functions (TF)
用户表 (U)
观看次数 (V)
SELECT *
FROM sys.columns
WHERE object_id=object_id('dbo.YourTVF')
这篇关于在 SQL Server 2008 R2 中获取表值函数的结果列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!