怎么查看一个与某个表有关联的存储过程

zhiaini 2009-09-10 10:50:32
比如,现在一个数据库里有很多表和很多存储过程
我怎么查看与其中某个表关联的存储过程?
...全文
426 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
pt1314917 2009-09-10
  • 打赏
  • 举报
回复

--or:
create proc wsp
@tablename varchar(50)
as
select sj.name from syscomments sc ,sysobjects sj
where sj.type='P' and sc.id=sj.id and ' '+sc.text+' ' like '% '+@tablname+' %'
and sj.uid=1 and sj.category=0
go
pt1314917 2009-09-10
  • 打赏
  • 举报
回复

--try:

create proc Get_pname
@tablename varchar(10) --要查询的表名
as
declare @name varchar(50),@pros varchar(1000)
create table ##(txt varchar(1000))
set @pros=''
declare wsp cursor for select name from sysobjects where xtype='p' and uid=1 and category=0
open wsp
fetch wsp into @name
while(@@fetch_status=0)
begin
exec('insert into ## exec sp_helptext '+@name)
if exists(select 1 from ## where ' '+txt+' ' like '% '+@tablename+' %')
set @pros=@pros+@name+','
fetch wsp into @name
end
close wsp
deallocate wsp
select @pros
go
水族杰纶 2009-09-10
  • 打赏
  • 举报
回复
--TRY
select sc.text,sj.name from syscomments sc ,sysobjects sj
where patindex('%'+sj.name+'%',sc.text)>0 and sj.type='U'
水族杰纶 2009-09-10
  • 打赏
  • 举报
回复
--TRY
select sc.text,sj.name from syscomments sc ,sysobjects sj
where patindex('%'+sj.name+'%',sc.text)>0 and sj.type='P'
soft_wsx 2009-09-10
  • 打赏
  • 举报
回复
没有必然联系
获得参数可以
xiequan2 2009-09-10
  • 打赏
  • 举报
回复
EXEC sp_depends '表'
--小F-- 2009-09-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhiaini 的回复:]
那要是存储过程的命名不规范.数据库又有几百个存储过程.
我现在写程序想用以前有的存储过程(以前的程序员写的),我得一个个去看?
或者我自己再写?
[/Quote]

基本是这样了
--小F-- 2009-09-10
  • 打赏
  • 举报
回复
一个一个慢慢找 两者没有什么必然的关联
zhiaini 2009-09-10
  • 打赏
  • 举报
回复
那要是存储过程的命名不规范.数据库又有几百个存储过程.
我现在写程序想用以前有的存储过程(以前的程序员写的),我得一个个去看?
或者我自己再写?
xuejiecn 2009-09-10
  • 打赏
  • 举报
回复
存储过程只测试语法的,不查看表在不在。
这个没有好办法。

只能从定义里找from了。
pt1314917 2009-09-10
  • 打赏
  • 举报
回复
呵呵。这个还真查不了。
触发器可以查,但存储过程无法查。。。
除非试试通过查询存储过程的内容去模糊查询。
黄_瓜 2009-09-10
  • 打赏
  • 举报
回复
一个个看
水族杰纶 2009-09-10
  • 打赏
  • 举报
回复
存儲過程與表沒有必然聯繫吧~~

34,593

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧