You can execute procedures with SET FMTONLY ON to identify those with
potentially problems. The script below (SQL 2000) will generate a
script to do this for all user stored procedures in the current
database. I'm not aware of a method to identify trigger errors, though.
SELECT
N'SET FMTONLY ON EXEC ' +
QUOTENAME(ROUTINE_SCHEMA) +
N'.' +
QUOTENAME(ROUTINE_NAME) AS ProcedureName,
REPLICATE(N'NULL,',
ISNULL((SELECT COUNT(*) AS Parameters
FROM INFORMATION_SCHEMA.PARAMETERS p
WHERE p.SPECIFIC_SCHEMA = r.ROUTINE_SCHEMA AND
p.SPECIFIC_NAME = r.ROUTINE_NAME), 0)) AS Parameters
INTO #FmtOnlyExecutes
FROM INFORMATION_SCHEMA.ROUTINES r
WHERE r.ROUTINE_TYPE = 'PROCEDURE' AND
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(ROUTINE_SCHEMA) +
N'.' +
QUOTENAME(ROUTINE_NAME)), 'IsMSShipped') = 0
GO
--remove trailing comma from parameter list
UPDATE #FmtOnlyExecutes
SET Parameters = LEFT(Parameters, LEN(Parameters) - 1)
WHERE RIGHT(Parameters, 1) = N','
GO
--generate EXEC script
SELECT RTRIM(ProcedureName) +
N' ' +
Parameters + N'
GO' --GO must be on separate line
FROM #FmtOnlyExecutes
ORDER BY ProcedureName
GO
DROP TABLE #FmtOnlyExecutes
GO
--
Hope this helps.
Dan Guzman
SQL Server MVP
-----------------------
SQL FAQ links (courtesy Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------
Quote:> I have found sp_refreshview quite useful in helping determine which of
my
> views might be broke because of schema changes etc. Is there
something
> equivalent for stored procedures and triggers? I would like some way
to
> proactive about validating my stored procs and triggers instead of
learning
> about problems when my app runs. Is anything available that does
this?
> Thanks very much.