Search

Monday, June 11, 2012

Recomplile all Stored Procedure of a Database

DECLARE proccurs CURSOR
FOR
    SELECT [name]
      FROM sysobjects
     WHERE xtype in ('p', 'v', 'fn')

OPEN proccurs
DECLARE @pname VARCHAR(60)

FETCH NEXT FROM proccurs INTO @pname
WHILE @@fetch_status = 0
BEGIN

    EXEC sp_recompile @pname

    FETCH NEXT FROM proccurs INTO @pname
END
CLOSE proccurs
DEALLOCATE proccurs

No comments:

Post a Comment