sql server - sql after insertion trigger update column within the same table -
im trying write trigger update column in same table when insertion done
my table
create table bluetooth ( id int primary key not null , version varchar(45) not null, score float null, speed float );
my trigger
create or replace trigger bluetoothsc on bluetooth after insert begin update bluetooth set score((select speed inserted)/(select max(speed) bluetooth ) * 100) end go
but errors in "incorrect syntax near" "or"
keyword in first line , "incorrect syntax near" "as"
can 1 please me
i want update bluetooth
tables score
column (inserted speed / max(speed) ) * 100)
when faster version of bluetooth came in should the score value 100 , others should lower value respectively.
instead of storing score, prefer instead calculate @ point of query. so, in case, view should job:
create table bluetooth ( id int primary key not null , version varchar(45) not null, speed float ); go create view bluetoothscores select id, version, speed, speed * 100 / max(speed) on () score bluetooth
and don't need worry triggers or update routines - results correct because they're calculated real data
Comments
Post a Comment