Solved

Trigger on "CREATE TABLE"

Posted on 2004-08-18
5
352 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
ID: 11832595
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
ID: 11832596
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
ID: 11834571
FYI: SQL Server 2005 does support this.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

777 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