查询返回有关 SQL Server 数据库中存储函数的内部详细信息
我已获得对当前由 3rd 方应用程序使用的 SQL Server 数据库的访问权限。因此,我没有任何关于该应用程序如何存储数据或如何检索数据的文档。
我可以根据各种表的名称以及用户定义函数接受和返回的参数来弄清楚一些事情,但我仍然每次都会遇到错误。
我在想,如果我能看到存储的函数使用给定的返回输出的参数做了什么,那将会非常有帮助。现在我能弄清楚的是如何查询输入参数和输出列。
是否有任何内置 information_schema
表可以公开函数在输入和输出之间执行的操作?
I have been given access to a SQL Server database that is currently used by 3rd party app. As such, I don't have any documentation on how that application stores the data or how it retrieves it.
I can figure a few things out based on the names of various tables and the parameters that the user-defined functions takes and returns, but I'm still getting errors at every other turn.
I was thinking that it would be really helpful if I could see what the stored functions were doing with the parameters given to return the output. Right now all I've been able to figure out is how to query for the input parameters and the output columns.
Is there any built-in information_schema
table that will expose what the function is doing between input and output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您可以以某种方式对数据库执行查询,并且您具有读取系统目录视图所需的权限,那么您可以运行此查询来获取名称、定义(SQL 代码)以及有关以下内容的更多信息:你的职能:
If you can execute a query against your database somehow, and if you have the necessary permissions to read the system catalog views, then you could run this query to get the name, the definition (SQL code) and a few more bits of information about your functions:
如果您有适当的权限,您可以简单地编写所有存储过程和函数的脚本:
在 SSMS (SQL Server Management Studio) 中右键单击您的数据库,选择“任务”–>“任务”。生成脚本,确保突出显示您的数据库,然后单击下一步。确保选择编写存储过程和函数脚本的选项。
您无需 SQL Server 许可证即可安装 SSMS(客户端工具)。
Provided you have appropriate permissions, you can simply script out all Stored Procedures and Functions:
Right-click on your database in SSMS (SQL Server Management Studio), select Tasks –> Generate Scripts, ensure your database is highlighted and click next. Ensure the options to script out Stored Procedures and Functions are selected.
You can install SSMS (client Tools) without requiring a SQL Server license.
另一种方法是
sp_helptext
,它将显示传递的 SP 或 UDF 的来源;sp_helptext fnBlaDeBla
Another way is
sp_helptext
which will show you the source of the passed SP or UDF;sp_helptext fnBlaDeBla