Link to home
Start Free TrialLog in
Avatar of stang1
stang1

asked on

SQL Server 2005 insert trigger

SQL Server 2005 - I'm trying to update a column as the user inserts into the db.  This is my first SQL Server trig and I keep getting a syntax error near 'BEGIN'.  Any ideas???
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TRIGGER trg_New_Trigger
   ON  dbo.Table1
   FOR INSERT AS UPDATE
 
BEGIN
 
		SET NOCOUNT ON;
 
UPDATE dbo.Table1
SET Target_Column = (Select substring(cast(getdate() AS CHAR(11)),10,2) + cast(ID_Field AS CHAR(10))
                       From inserted)
WHERE Table1.RowID IN (SELECT RowID FROM inserted)
END
GO

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stang1
stang1

ASKER

I think you answered the question - thanks!  I still get: Msg 207, Level 16, State 1, Procedure trg_Update_Offer_Ref_ID_Yr, Line 16
Invalid column name 'ROWID'.  Do we DECLARE a rowid in SQL Server 2005?  I'll see if I can debug it.  Thanks Again.