Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Trigger on table field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-12-08 : 08:09:22
Hemant writes "my database contains table1
in this table1

there are two fields
ap as tinyint
st as char(3)

i want to creat a trigger

if st <> 'cls'
so ap = 0
else
so ap = 1

please help me"

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-08 : 08:25:38
You need to use the pk on the table
create trigger tr on table1
as
update table1
set ap = case when i.st <> 'cls' then 0 else 1 end
from inserted i
where i.pk = table1.pk



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -