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.
Author |
Topic |
farnooshhp
Starting Member
1 Post |
Posted - 2009-03-18 : 03:15:46
|
helloi am new in triggers!! i have a table1 with a count field and i want to increase it when table2 will be inserted.how can i write trigger for this purpose?is this correct? create trigger addconton table2after insertasupdate table1 set count = count+1 where id = table2id and two tables are connected with id field |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-18 : 03:54:02
|
[code]create trigger addconton table2after insertasupdate t1 set [count] = [count]+1 from table1 as t1 inner join inserted as i on i.id = t1.id [/code] E 12°55'05.63"N 56°04'39.26" |
|
|
|
|
|