Solved

Trigger on "CREATE TABLE"

Posted on 2004-08-18
5
342 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.

895 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

14 Experts available now in Live!

Get 1:1 Help Now