sql server find string and alter stored procs and views (oldValue, newValue). no execute! be patient....

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

 DECLARE @SSQL NVARCHAR(4000)

 SET @SSQL ='SELECT
    b.Name                                                                      AS [ObjectName],
    CASE WHEN b.type ="p" THEN "Stored Procedure"
         WHEN b.type ="v" THEN "View"
         ELSE b.TYPE
    END                                                                         AS [ObjectType]
    ,a.definition                                                               AS [Definition]
    ,Replace ((REPLACE(definition,"oldvalue","newValue")),"Create","ALTER")   AS [ModifiedDefinition]
FROM sys.sql_modules a
JOIN
(   select type, name,object_id
    from sys.objects
    where type in (
            "p" -- procedures
            ,"v"--views
                   )
  and is_ms_shipped = 0
 )b
ON a.object_id=b.object_id '


 EXECUTE sp_executesql @SSQL

Yorumlar