..NET Developer (pleasereplytogroups@hotmail.com) writes:
> I would like to create my first simple trigger, but when I try to save
> the trigger inside Enterprise Manager, it gives me the following
> error:
>
> Error 21001 : [SQL-DMO] Stored procedure definition must include name
> and text (for Standard StoredProcedure) or libraryname (for Extended
> StoredProcedure).
>
> The actual trigger itself is, I think, fairly straight forward:
>
> CREATE trigger UpdateCache
> on MyTable
> for update, delete, insert
> as
> declare @cmd varchar(200)
> select @cmd = 'echo ' + cast(getDate() as varchar(50)) + ' >
> c:\tablechange.txt'
> exec master..xp_cmdshell @cmd, no_output
I don't know what you plan to do for real in your trigger, but be wary
with calling xp_cmdshell from a trigger. A trigger executes in the
context of a transaction, and you are holding locks. If the trigger
runs for too long, and it is an intensive system, you may block other
processes.
--
Erland Sommarskog, SQL Server MVP,
sommar@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp