Hi Bob,
The syntax seems find. =20
Could you be in the wrong database? Please post he DDL and I can test =
some more.
kind regards
Greg O
-------
Looking to use CLR in SQL 2005. Try some pre-build CLR Functions and SP
AGS SQL 2005 Utilities, over 20+ functions
http://www.ag-software.com/?tabid=3D38 [quoted text, click to view] "Bob" <bdufour@sgiims.com> wrote in message =
news:OCtEay86FHA.1020@TK2MSFTNGP15.phx.gbl...
Been doing triggers for years in sql 2000 now I find I got triggers =
that worked in a previous versions but I can no longer just pick up and =
paste my code in sql 2005 triggers. One sample.
I'm in mydb on myserver and have a table mytable with two fields =
LastupdateOn and LastUpdateBy, I want to update these witha trigger. So =
I right click on triggers in my database, select new trigger, now I get =
this template that I fill out.=20
-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters=20
-- command (Ctrl-Shift-M) to fill in the parameter=20
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
-- Author: Robert Dufour
-- Create date: Nov 17 2005
-- Description: Used to set the lastupdate fields
-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
CREATE TRIGGER trg_Mytable_ins_upd=20
ON Mytable
AFTER INSERT,UPDATE
AS=20
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for trigger here
Update Mytable
Set LastUpdateBy =3D Suser_sname(),
LastUpdateOn =3D GetDate()
Where Exists (select * from inserted where inserted.Id=3D Mytable.Id)
END
GO
This worked fine in 2000, in 2005 now I find I have to execute this =
query to create the trigger and when I do I get following error message
Msg 8197, Level 16, State 4, Procedure trg_Mytable_ins_upd , Line 6
Object 'Mytable' does not exist or is invalid for this operation.
What gives here? Why does Mytable that I have already created and is =
correct not get recognized. What do I need to do to create a trigger =
now. Any help appreciated.