79670198

Date: 2025-06-18 07:38:26
Score: 5
Natty:
Report link

after executing this script: matching the findtext sp is dropped and i cannot find the SP in the database !! ideally updated SP should be there...
not working for me.

Declare @spnames CURSOR
Declare @spname nvarchar(max)
Declare @moddef nvarchar(max)
Set @spnames = CURSOR FOR
select distinct object_name(c.id) 
from syscomments c, sysobjects o 
where c.text like '%findtext%'
and c.id = o.id
and o.type = 'P'    
OPEN @spnames
FETCH NEXT
FROM @spnames into @spname
WHILE @@FETCH_STATUS = 0
BEGIN   
    Set @moddef =
    (SELECT
    Replace ((REPLACE(definition,'findtext','replacetext')),'ALTER','create')
    FROM sys.sql_modules a
    JOIN 
    (   select type, name,object_id
    from sys.objects b
    where type in (
    'p' -- procedures
    )
    and is_ms_shipped = 0
    )b
    ON a.object_id=b.object_id where b.name = @spname)              
    exec('drop procedure dbo.' + @spname)
    execute sp_executesql @moddef
    FETCH NEXT FROM @spnames into @spname
END
Reasons:
  • Blacklisted phrase (1.5): i cannot find
  • Blacklisted phrase (0.5): i cannot
  • RegEx Blacklisted phrase (3): not working for me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Arsha Hasan