David Emerson
newsgrps at dalyn.co.nz
Sat Jan 14 12:42:21 CST 2006
I think I have got round similar problems by creating the table as a normal table, creating the trigger and saving it, then deleting the table. HTH David Emerson Dalyn Software Ltd New Zealand At 15/01/2006, you wrote: >I'm using Express Management Studio to create a trigger that uses the >temporary inserted table to update inventory -- simple example, but I get an >error that the schema in the target table doesn't match the trigger schema. >My guess is it doesn't like the use of inserted as a table name because at >the time I'm creating the trigger it doesn't exist. If that's the case, I >don't know how to get around that. > >Here's the trigger: > >CREATE TRIGGER UpdateInventory ON Sales.dbo.Orders >AFTER INSERT >AS >BEGIN > UPDATE Products > SET Products.InStock = (Products.InStock - Inserted.Qty) > FROM Products JOIN Inserted ON Products.ProdID - Inserted.ProdID >END >GO > >I've checked the column names, just to be sure, and they above in correct in >that respect. I've run into trouble using the inserted temporary table >before, but I don't remember how I skirted it. > >Susan H.