Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqldba20
Posting Yak Master
183 Posts |
Posted - 2007-10-18 : 16:35:36
|
| Folks:I want to run sp_recompile on a weekly basis. Does anybody have a script / stored procedure which will get all the Stored Procedures and Tables from a database and do a recompile. I wrote this small script but it is giving me a error as "Incorrect syntax near 'sp_recompile'."CREATE PROCEDURE usp_RecompileASDECLARE @ObjName varchar(255)DECLARE @Statement nvarchar(255)DECLARE @Command varchar(255)DECLARE ObjCursor CURSOR FORSELECT name FROM sys.objectswhere type in ('P','U')OPEN ObjCursorFETCH NEXT FROM ObjCursor INTO @ObjNameWHILE @@FETCH_STATUS = 0BEGINPRINT 'RECOMPILING ' + @ObjNamesp_recompile (@ObjName)--SET @Statement = 'UPDATE STATISTICS ' + @TableName + ' WITH FULLSCAN'--EXEC sp_executesql @StatementFETCH NEXT FROM ObjCursor INTO @ObjNameENDCLOSE ObjCursorDEALLOCATE ObjCursorThanks !! |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-10-18 : 16:47:32
|
| shouldn't it be:exec sp_recompile @ObjName ?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
|
|
|