You are here: Re: Trigger on a table in TempDB « MsSQL Server « IT news, forums, messages
Re: Trigger on a table in TempDB

Posted by Erland Sommarskog on 08/22/06 08:14

Karthik (karthiksmiles@gmail.com) writes:
> I have an application that creates and makes use of a table in tempdb.
> My problem is that I have a couple of triggers on this table that get
> dropped everytime SQL Server restarts (due to the fact that tempdb gets
> recreated). Is there a way to automatically recreate these triggers
> each time SQL Server starts? It looks like it is not possible to have a
> "create trigger" statement within a stored procedure. I would greatly
> appreciate some ideas....thanks in advance!

You can say:

EXEC ('CREATE TRIGGER ...')

in your stored procedure (that you would set up as a start-up procedure
for the server).

However, the design sounds dubious to me. Why have the table in tempdb?
Why not in a user database?


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация