1

I want to query the metadata of my Database for any Stored Proc that returns the values from a field or column named "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:

; 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:

; 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:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'FROM'.

Is [specific_name] wrong for this type of query? Is COLUMNS or [COL_NAME] wrong for this type of query?

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"?

4

1 回答 1

1

您可以使用sp_describe_first_result_set它从 tsql 批处理返回元数据。看看https://msdn.microsoft.com/en-us/library/ff878602%28v=sql.110%29.aspx

于 2015-12-11T16:55:42.003 回答