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

stang1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TRIGGER trg_New_Trigger
   ON  dbo.Table1
   FOR INSERT,  UPDATE
 AS
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stang1Author Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.