[英]How can I query my Database for any Stored Proc that returns a field/column value of a specific name?
I want to query the metadata of my Database for any Stored Proc that returns the values from a field or column named "bidprice" 我想查询数据库的元数据中是否有任何存储过程,这些存储过程从名为“ bidprice”的字段或列中返回值
I got a great answer here for how to search for Stored Procs that require a specific set of parameters, namely for Stored Procs that have parameters named Unit, Member, BegDate, and EndDate, this: 我有一个很好的答案在这里了解如何搜索需要一组特定的参数,即对于有冠名单位,会员,BegDate,日期和结束日期,该参数存储的特效存储的特效:
; WITH T AS (SELECT [specific_name] FROM information_schema.parameters WHERE [parameter_name] = '@Unit'
UNION ALL
SELECT [specific_name] FROM information_schema.parameters WHERE [parameter_name] = '@Member'
UNION ALL
SELECT [specific_name] FROM information_schema.parameters WHERE [parameter_name] = '@BegDate'
UNION ALL
SELECT [specific_name] FROM information_schema.parameters WHERE [parameter_name] = '@EndDate')
SELECT [specific_name]
FROM T
GROUP BY [specific_name] HAVING COUNT(*) = 4
That works perfectly; 那很好用; and so I hoped that maybe what I needed to find Stored Procs that return a field/column value of a specific name, such as "bidprice" might be something as simple as this:
因此,我希望也许可能需要找到返回特定名称的字段/列值(例如“ bidprice”)的存储过程,就像下面这样简单:
; SELECT [specific_name] FROM information_schema.COLUMNS WHERE [COL_NAME] = "bidprice"
FROM T
...but trying it in Visual Studio.Server Explorer (right-clicking on the database connection's Tables folder, and then selecting New Query), I get: ...但是在Visual Studio.Server Explorer中尝试一下(右键单击数据库连接的Tables文件夹,然后选择New Query),我得到:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'FROM'.
Is [specific_name] wrong for this type of query? 这种类型的查询的[specific_name]错误吗? Is COLUMNS or [COL_NAME] wrong for this type of query?
这种查询类型是否为COLUMNS或[COL_NAME]?
I also tried to simplify the query this way: 我还尝试通过这种方式简化查询:
; SELECT [specific_name] FROM information_schema.COLUMNS WHERE [COL_NAME] = "bidprice"
...but got: ...但是得到:
Msg 207, Level 16, State 1, Line 1
Invalid column name 'COL_NAME'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'bidprice'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'specific_name'.
(and the same exact err when removing the prepended ";") (和删除前置的“;”时的错误完全相同)
What is the right way to search for Stored Procs that return in their result set (among/amidst whatever else) a field/column named "bidprice"? 什么是搜索在结果集中返回的存储过程(其中包括/除其他以外)名为“ bidprice”的字段/列的正确方法?
You could use sp_describe_first_result_set
this returns the metadata from tsql batch. 您可以使用
sp_describe_first_result_set
返回sp_describe_first_result_set
批处理中的元数据。 Take a look at https://msdn.microsoft.com/en-us/library/ff878602%28v=sql.110%29.aspx 看看https://msdn.microsoft.com/zh-cn/library/ff878602%28v=sql.110%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.