sql server - Syntax check all stored procedures? -
I want to make sure that all stored processes are still valid syntax. (This can happen when a person designates / removes the table / column).
Now to check the syntax of all stored procedures, I have to go to Enterprise Manager, select the first stored procedure in the list, and use the process:
- Enter
- Alt + C
- Escape
- Escape
- Down Arrow
- Goto 1
it works, but it is very tedious I have a stored procedure that
Syntax Czech Sbistresprokdrs
No Of the other stored procedures would like the same thing that he thought what I wrote:
RefreshAllViews
All For the benefit, RefreshAllViews:
RefreshAllViews.prc
Processing Deborah. Refresh Elviz AS - This will refresh all the views in the SP Catalog. - an analysis seen it all, and select runs sp_refreshview for each ABC cursor declaration TABLE_NAME ViewName the INFORMATION_SCHEMA.VIEWS Select declared open ABC @ViewName varchar (128) - Create a string declared nvarchar ( 2048) Next access from @SQLString ABC INTO @ViewName WHELE @@ FETCH_STATUS = 0 BEGIN SET @SQLString = 'EXCUTE sp_RefreshView' + @ViewName Print @SkualString EXCUTE SP_Execute SQL @SQL String FETCH so far @ViewName END Close in ABC DEALLOCATE ABC
< RecompileAllStoredProcedures: hr> As for the benefit of all, a stored procedure will require a recompile (recompile if marking a stored procedure will not tell you the syntax is valid); To mark all stored procedures in PRC
process resulting from INFORMATION_SCHEMA.routines to choose ROUTINE_NAME as dbo.RecompileAllStoredProcedures declared ABC cursor where announced ROUTINE_TYPE = 'process' open ABC @RoutineName varchar (128) - Select the selection string once DECLARE @SQLString nvarchar (2048) Abc INTO @ RoutineName WHILE @@ FETCH_STATUS = 0 BEGIN SET @SQLString = 'EXPUTE sp_recompile' + @ RoutineName print @SQLString EXECUTE sp_ExecuteSQL @ SQLString ABC from FETCH @RoutineName end next come off ABC reallocation ABC
for the sake of fulfillment U PdateAllStatistics process. It will be updated in a full scan all data in the database by data:
As RefreshAllStatistics.prc
dbo.RefreshAllStatistics crea Execute sp_msForEachTable 'Update Statistics? You can also "In-Place" with the complete '
without all
Now you can get rid of your step 2 and execute each process retrieved in step 1.Here is a sample using a personal stored procedure. You can work it in your favorite loop:
Create process test @bob int select * set by missing_table_or_view at showplan_text; The sample given above should produce the following output: Message 208, Level 16, State 1, Process Test, Line 2
Invalid Object The name of 'missing_table_or_view'