Check for invalid triggers

Is there an automated/scripted way to check whether there are any invalid triggers in a database? Invalid meaning column type mismatches etc.

Answers


You could extract and modify the scripts for the triggers and catch exceptions on executing ALTER statements.

SELECT ID, Name
     , REPLACE(SQL, 'CREATE TRIGGER', 'ALTER TRIGGER') 
       + CHAR(13) + CHAR(10) + 'GO'  as SQL 
FROM
(                             
SELECT ID,name , SQL = STUFF( (SELECT ' ' + CAST(Text as varchar(max))
                                FROM sys.Syscomments c 
                                WHERE c.id =s.ID 
                                ORDER BY  colid
                                FOR XML PATH(''), type
                                ).value('.', 'nvarchar(max)')
                            , 1, 1, '')
FROM sys.sysobjects AS s
WHERE xtype = 'P'
) x

Need Your Help

HTML forms for (repeated=True) properties

python forms google-app-engine gae-datastore

How do I handle value(s) from a html form which is using a repeated=True property?

iOS - Getting value from UIPicker, where item is a relationship

xcode core-data ios6 uipicker

I am trying to use the value from a UIPicker in a core-data app.