Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:25:52+00:00 2026-06-17T11:25:52+00:00

I have SQL Server 2008 R2. I have around 150 tables in a database

  • 0

I have SQL Server 2008 R2. I have around 150 tables in a database and for each table I have recently created triggers. It is working fine in my local environment.

Now I want to deploy them on my live environment. The question is I want to deploy only the triggers.
I tried the Generate Script wizard but it is creating script with table schema along with triggers, NOT triggers only.

Is there anyway to generate all the triggers drop and create type script?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:25:53+00:00Added an answer on June 17, 2026 at 11:25 am

    Forget the wizard. I think you have to get your hands dirty with code. Script below prints all triggers code and stores it into table. Just copy the script’s print output or get it from #triggerFullText.

    USE YourDatabaseName
    GO
    SET NOCOUNT ON;
    
    CREATE TABLE #triggerFullText ([TriggerName] VARCHAR(500), [Text] VARCHAR(MAX))
    CREATE TABLE #triggerLines ([Text] VARCHAR(MAX))
    
    DECLARE @triggerName VARCHAR(500)
    DECLARE @fullText VARCHAR(MAX)
    
    SELECT @triggerName = MIN(name)
    FROM sys.triggers
    
    WHILE @triggerName IS NOT NULL
    BEGIN
        INSERT INTO #triggerLines 
        EXEC sp_helptext @triggerName
    
        --sp_helptext gives us one row per trigger line
        --here we join lines into one variable
        SELECT @fullText = ISNULL(@fullText, '') + CHAR(10) + [TEXT]
        FROM #triggerLines
    
        --adding "GO" for ease of copy paste execution
        SET @fullText = @fullText + CHAR(10) + 'GO' + CHAR(10)
    
        PRINT @fullText
    
        --accumulating result for future manipulations
        INSERT INTO #triggerFullText([TriggerName], [Text])
        VALUES(@triggerName, @fullText)
    
        --iterating over next trigger
        SELECT @triggerName = MIN(name)
        FROM sys.triggers
        WHERE name > @triggerName
    
        SET @fullText = NULL
    
        TRUNCATE TABLE #triggerLines
    END
    
    DROP TABLE #triggerFullText
    DROP TABLE #triggerLines
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a set of tables (around 20) in SQL Server 2008 and
I have SQL Server 2008 Ent and OLTP database with two big tables. How
I have created SQL Server 2008 Database project using visual studio 2010. after build
I have an SQL Server 2008 database with a table that has a column
I have an EMPLOYEE table in a SQL Server 2008 database which stores information
Playing around with SQL Server 2008 and I have a table People with columns:
I have a simple database table (SQL Server 2008 R2 Express), which has a
Just a SQL Server 2008 generic question, I have a table that has around
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have SQL Server 2008 R2 and one of my tables has a date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.