Solved

Trigger on "CREATE TABLE"

Posted on 2004-08-18
5
332 Views
Last Modified: 2008-03-06
Is it possible to have a trigger fire off when a table is created? I know it's not possible to add a trigger to the sysobjects table, and I think I'll just have to run a process to check for changes every once in a while. I would like to see if anybody knows if this can be done though. I'm modifying some 3rd party software, and there is a set of tables that only exist when specific user-defined fields are created in the software. I'm attaching triggers to those tables, but I can obviously only attach them after the tables have been created, so I would basically like a trigger that creates a trigger on a newly created table. Anybody know if this can be done?
0
Comment
Question by:espeir
5 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 500 total points
Comment Utility
Nope, trigger definitions are associated with a specific table, and you're right, it's not allowed on sysobjects, which is the only one that might help. Periodic checks are the way to go.
0
 
LVL 10

Expert Comment

by:kiranghag
Comment Utility
Hi espeir,
create a test database and try to put the trigger on the sysobject table

this table is updated whenever a db object is created ...

but whats your specific requirement?

Kir@n

0
 
LVL 18

Expert Comment

by:SjoerdVerweij
Comment Utility
FYI: SQL Server 2005 does support this.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now