Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

SQL triggers query

$
0
0
Hi, this is my first post on sqlservercentral. I am trying to learn about triggers, I know how to do really basic ones, but I can't wrap my head around this. I have two tables Services(master) and Sales.Services(ServiceID,ServiceCost,SalesTotal)Sales(TransactionID,TransactionDate,Amount,ServiceID)I am trying to write trigger for Update,Delete,Insert. When ever you enter a new sale in the Sales table, the SalesTotal will get updated in the Services table according to ServiceID.ex: INSERT INTO Sales(TransactionID,TransactionDate,Amount,ServiceID)VALUES ('16','2014-11-19','50','101');So if the SalesTotal for TransactionID '101' was 1000, after the insert it would be 1050.

Viewing all articles
Browse latest Browse all 3145

Trending Articles