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 2005 Forums
 Transact-SQL (2005)
 Helppppppp...

Author  Topic 

jawidjawid
Starting Member

1 Post

Posted - 2009-03-31 : 16:17:41
Dear all,
I am working on a project(Inventory control system for a pharmacy) for my college semester exams,
there I want to connect two tables
1: stock and 2: sales
In the stock table I have all the Items.
what I want is, when there is a sale in my sales table It should affect my stock tale, like the number of items sold should be decreased in the stock table...
jawid


jawid

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-03-31 : 16:25:33
You can do this via a trigger or a cascading foreign key, although I would just add the UPDATE statement to the stored procedure or wherever your database code will reside.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

BJM RAO
Starting Member

20 Posts

Posted - 2009-04-01 : 12:55:29
A insert/update tirgger or an SP will suffice on stock table
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-01 : 13:19:18
i would have put this logic also in sale procedure with both of the logic wrapped in a transaction.
Go to Top of Page
   

- Advertisement -