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 |
|
nangitoholmes
Starting Member
3 Posts |
Posted - 2011-03-02 : 10:40:10
|
| Hi all,I was looking for help with an update triger.What I want is to run a trigger that will automatically update a table in my database. Eg:If column a is updated to lets say 10column b is updated to column a + column bIs that possible?What I have tried so far is:create trigger points_trigbefore update on squadif update(weekly_points)begin update latest_points set latest_points = inserted.weekly_points + latest_points end |
|
|
nangitoholmes
Starting Member
3 Posts |
Posted - 2011-03-02 : 12:25:25
|
| create trigger points_trigafter update of weekly_points on squadfor each rowEXECUTE PROCEDURE update_points() end;CREATE PROCEDURE update_points()UPDATE squadSET latest_points = weekly_points + latest_points;Updated it to this but still gettin errors on the trigger.. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nangitoholmes
Starting Member
3 Posts |
Posted - 2011-03-03 : 08:58:59
|
| CREATE TABLE IF NOT EXISTS SQUAD (player_id int not null auto_increment primary key,player_name varchar(25) not null,player_image varchar(100),player_dob date not null,player_position varchar(25) not null,county_id int not null,weekly_points int,latest_points int,overall_points int);ALTER TABLE SQUADADD (CONSTRAINT county_fk FOREIGN KEY (county_id)REFERENCES counties(county_id));ALTER TABLE SQUADADD (CONSTRAINT position_fk FOREIGN KEY (player_position)REFERENCES Position(position_id));Overall points has been dropped since.. |
 |
|
|
|
|
|