Dear All,
I just created two triggers inroder to insert the workorder info into the tables (Purchaseorder and purchaseorderentry). the triggers are created on order,orderentry tables respectively. After creating the work order when i check the database, i saw the integrity between order and orderentry tables lost. the orderid field of orderentry table refering to the the field id in order table is different. CREATE TRIGGER INSERT_PO ON [ORDER] FOR INSERT AS declare @tpId as integer declare @PoNm as integer declare @Potype as integer set @Potype=2 set @PoNm=(select isnull(max(ponumber),0)+1 from PurchaseOrder) insert into PurchaseOrder(potype,ponumber,storeid,[to],shipto,lastupdated,datecreated,remarks,otherstoreid) select @Potype,@PoNm,i.storeid,'WAREHOUSE','SHOWROOM',i.lastupdated,getdate(),i.id,@Potype from inserted i
CREATE TRIGGER INSER_PO_ENTRY ON ORDEREntry FOR INSERT AS declare @tpId as varchar(10) declare @tpId_C as integer set @tpID=(select orderid from inserted) set @tpId_C=(select id from purchaseorder where remarks=ltrim(rtrim(@tpID))) insert into purchaseorderentry(purchaseorderid,itemdescription,itemid,lastupdated,storeid,quantityordered,price) select @tpId_C,[description],itemid,lastupdated,storeid,quantityonorder,price from inserted i
Any Help will be appreciated, Thanks in Advance,
Ibrahim Zubair
---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane.