Find all triggers that contain FACTS in trigger name

  • i cant seem to write a query to find all triggers in a database that contain the word FACTS in it

  • Tried this?

    SELECT * FROM sys.[triggers] AS [t]
    WHERE [t].[name] LIKE '$FACTS%';

  • When you say contain the word "FACTS", where does it contain it? In the name of the object (trigger)? The name of the table it is attached to? The word "FACTS" is in the SQL it runs?

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Or perhaps this if you are looking for FACTS in the trigger definition.

    SELECT *
    FROM
      [sys].[sql_modules] AS [sm]
      INNER JOIN [sys].[triggers] AS [t]
        ON [t].[object_id] = [sm].[object_id]
    WHERE
      [sm].[definition] LIKE '%FACTS%';

  • yes in the name of the trigger there are a lot of tables and we need a list of all triggers that contain the name FACT in the title of the trigger

  • My first query.

  • no FACTS will just be in the trigger name

  • myukas - Thursday, November 30, 2017 9:53 AM

    no FACTS will just be in the trigger name

    Yes, the query will find all trigger names that contain the word FACTS.  The FIRST query I posted, not the second one.

  • Lynn Pettis - Thursday, November 30, 2017 9:54 AM

    myukas - Thursday, November 30, 2017 9:53 AM

    no FACTS will just be in the trigger name

    Yes, the query will find all trigger names that contain the word FACTS.  The FIRST query I posted, not the second one.

    Sorry, just noticed a typo:

    SELECT OBJECT_NAME([t].[parent_id]),* FROM sys.[triggers] AS [t]
    WHERE [t].[name] LIKE '%FACTS%';

  • thanks

  • when i run that against the database it returns nothing but my client says they do exist
    Find the tables having Triggers starting with ‘FACTS’ and dump in excel
    USALL-RS03 in GPMGlobal, CDSAllentown, CDSBasel, CDSHorsham, CDSBillingAllentown, CDSBillingBasel, CDSBillingHorsham

  • If Lynn's query is returning no results, then there are no triggers with the word "FACTS" in their name in that database.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Here is an idea, drop the WHERE clause and visually inspect the name column.

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply