gpt4 book ai didi

sql-server - 列出所有没有参数的存储过程

转载 作者:行者123 更新时间:2023-12-01 06:21:43 24 4
gpt4 key购买 nike

我想找出数据库中哪些存储过程没有参数。我试过这些,但我不确定:

1) 连接表sys.all_parameterssys.all_objects :

select 
ao.name,ao.type, ao.type_desc
from
sys.all_parameters pa
left outer join
sys.all_objects ao
on pa.object_id = ao.object_id
where
pa.name like ''
and
ao.type not in ('FN','AF','FS')

2) 从表 information_schema.parameters :
select * 
from
information_schema.parameters
where
parameter_mode not in ('in', 'out', 'inout')

3) 来自 information_schema.parameters :
select * 
from
information_schema.parameters
where
parameter_name like ''

但是,我不完全确定这些是否正确。有什么直接的方法吗?

也许是这样的:
select * from sys.procedures where xtype = 'P' and has_parameters=0

最佳答案

SELECT SCHEMA_NAME(schema_id) AS schema_name,
name
FROM sys.procedures pr
WHERE NOT EXISTS(SELECT *
FROM sys.parameters p
WHERE p.object_id = pr.object_id)

关于sql-server - 列出所有没有参数的存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14708624/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com