in addition to Andrew, I think you can check for the specfic column as well.
see
http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/af92ec70c1febf6b/6cf93cbe4776f30e?hl=en&lnk=st&q=inserted+Employee+trigger+sloan#6cf93cbe4776f30e
for the original post..
here is a sample, you could alter to fit your need.
Notice the "if update(HireDate)"
Notice (as Andrew mentioned) that the trigger runs ONCE per set. So if you
update 10 rows, the trigger runs once (this is the most common error I see)
And finally, Notice that the inserted table gets populated on INSERTS or
UPDATES ( if you define it as such with the "For Update, Insert" clause).
Here is a generic example. This runs for Employees, and the HireDate of
"01/01/2000". (Obviously a silly example, but you can figure out your own
needs based on the sample)
This assumes a dbo.Employee table with a EmployeeUUID (guid, primary key)
and HireDate (datetime) column.
CREATE TRIGGER trgExample1
ON dbo.Employee
FOR UPDATE , INSERT
AS
BEGIN
IF UPDATE(HireDate)
BEGIN
--print '..(inserted).............................................'
-- select * from inserted
--print '----------------------------------------------------------'
Select *
FROM
dbo.Employee emp INNER JOIN inserted ins
ON ins.EmployeeUUID = emp.EmployeeUUID
AND inserted.HireDate = '01/01/2000' --<< this would be your
resolved flag here
--print ''
--print '/Start Trigger Info/'
--print 'Trigger Fired (Should only fired once, even for bulk update)'
--print @updateCount
--print '/End Trigger Info/'
--print ''
END
END
Go
[quoted text, click to view] "Lord Kelvan" <the_iddiot@hotmail.com> wrote in message
news:1192234150.296704.144720@k35g2000prh.googlegroups.com...
> ok i cannot for the life of me remember how to do this nor can i find
> what i am looking for
>
> i am trying to update my database when a value is updated into the
> database
>
> in one table i have somevalues and a two other peices of information
> resolved and dateresolved i want my trigger to update the date
> resolved informaion using getdate() when a 1 is entered into the bit
> field resolved
>
> -- ================================================
> -- Template generated from Template Explorer using:
> -- Create Trigger (New Menu).SQL
> --
> -- Use the Specify Values for Template Parameters
> -- command (Ctrl-Shift-M) to fill in the parameter
> -- 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.
>
> =====================================================
> CREATE TRIGGER dbo.addresolveddate
> ON dbo.ISSUE
> FOR UPDATE
> AS
> BEGIN
> IF resolved = 1
> BEGIN
> update issue set dateresolved = getdate()
> END
>
> END
> =====================================================
>
> all of that works of course except the if command because it does not
> kwow what resolved is at that time which under programming logics is
> correct please help me get that to work so when the interface updates
> that column with a 1 it runs said trigger
>
> regards
> Kelvan
>