Date Last Modified SQL Trigger & Display Script

I have a MS SQL Database. With a table named Products. Field name pID (pri Key) and pModified (smalltimedate). I have approx. 2000 products entered. I have to edit each product with HTML in my site admin section. currently it looks like this on the product listing*** 28451 African lady*** . I would for it to be     *** 28451 African lady last modified 11/24/04 6:42pm***. This is to show which products have been modified. I am new to SQL Database, using EMS SQL Manager and frontpage 2003. It is an ASP Site. I would like to know how to create the trigger and a small script to show the last modified time/date on the webpage.
awestryAsked:
Who is Participating?
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.

LowfatspreadCommented:
trigger

create trigger Trg_Upd_Products
on table dbo.products
for UPDATE

as

Update Products
 set Pmodified = getdate ()
 Where Products as P
Inner Joined Inserted as I
 on P.pid=I.pid

go


to display something like

select  '***' + convert(varchar(10),pid) + ' ' [Name]
              + coalesce(' ' + convert(varchar(20),pmodified),'') + ' ***'
from products
where pid=...

hth
 
0
awestryAuthor Commented:
CREATE TRIGGER [Trg_Upd_Products] ON [xxxxx_xxxx].[products]
FOR INSERT, UPDATE
AS
BEGIN
  set pModified = getdate ()
 Where Products as P
Inner Joined Inserted as I
 on P.pID=I.pid

END
GO

I tried the code above I get the error :Line 5: Incorrect syntax near '='
I am using EMS SQL Manager New Trigger Dialog.

note: ( xxxx was used on line 1 for forum post db password is correct )
0
LowfatspreadCommented:
>Inner Joined Inserted as I
should be
Inner Join Inserted as I
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
awestryAuthor Commented:
CREATE TRIGGER [Trg_Upd_Products] ON [xxxxx_xxxx].[products]
FOR INSERT, UPDATE
AS
BEGIN
  set pModified = getdate ()
 Where Products as P
Inner Join Inserted as I
 on P.pID=I.pid

END
GO

I tried the code above I still get the same error :Line 5: Incorrect syntax near '='
could the error be in the set pModified = getdate () statement

0
awestryAuthor Commented:
This is the final working Code


CREATE TRIGGER [Last_Modified_products_new] ON [awestry_giftsu].[products]
FOR UPDATE
AS
UPDATE products
SET pModified = GETDATE()
FROM products ytn
INNER JOIN inserted i ON ytn.pID = i.pID
GO

Thanks for the help
AW
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 SQL Server

From novice to tech pro — start learning today.