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
 Transact-SQL (2000)
 Help on Trigger

Author  Topic 

djsemite
Starting Member

1 Post

Posted - 2011-01-20 : 05:30:32
Question: When a new row is added to the Employee table, the iCurrentstrength (column) attribute of the Position table should be increased by one.
Now guys i need the syntax to create the INSERT trigger.OR any clue to go by it.
U guys are doing a great job here.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-20 : 05:37:55
create trigger tr_Employee on Employee for insert
as
update Position
set iCurrentstrength = iCurrentstrength + (select count(*) from inserted)
go

Doubt if that is exactly what you want but it will give you an idea.

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

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-01-20 : 05:39:16
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-20 : 10:21:26
Why do you need a trigger for this? Why dont you use a select statement to return the count? Do you want to populate a serial no?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -