SQL查看数据库中包含临时表的所有存储过程

使用游标过滤包含#开头的存储过程


declare @name varchar(300)

declare mycur cursor for
    select name from sysobjects o,syscomments s
    where o.id = s.id and o.xtype ='p' and text like '%#%' and o.xtypr = 'P'
open mycur
fetch next from mycur into @name
while @@FETCH_STATUS = 0
begin
    exec('exec sp_helptext ' + @name)
    fetch next from mycur into @name
end
close mycur
deallocate mycur
go

你可能感兴趣的:(SQL,sql,数据库,cursor)