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

LibGDX render only, if camera sees it

java optimization camera libgdx render

So, I have created my first game. on computer it works(60FPS) but on my mobile, I have 50FPS, and sometimes it jumps to 30 and back again, you see it like a lag. I have stored all objects in an Arr...

Accessing a Service from within an XNA Content Pipeline Extension

xna factory linq-to-xml pipeline

I need to allow my content pipeline extension to use a pattern similar to a factory. I start with a dictionary type: