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)
 Help with Trigger

Author  Topic 

argate7
Starting Member

7 Posts

Posted - 2009-04-13 : 12:10:25
Hi..

I'm using the trigger below and i have a problem.

create trigger OrdersNotDisc
on OrderDetails
for insert,update
as
if exists (select 'true' from inserted where inserted.ItemNo = Items.ItemNo and Items.ItemDiscontinued =1)
begin
Raiserror('Order Item discontinued. Tsansaction Cancelled',10,1)
rollback
end


the problem that i'm facing is :
Msg 4104, Level 16, State 1, Procedure OrdersNotDisc, Line 5
The multi-part identifier "Items.ItemNo" could not be bound.
Msg 4104, Level 16, State 1, Procedure OrdersNotDisc, Line 5
The multi-part identifier "Items.ItemDiscontinued" could not be bound.


So now what can i do? Does anybody know? Thank you very much.

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-04-13 : 13:20:23
you have no table called Items in that select

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-04-13 : 13:20:56
The problem is you are referring items.itemNo but your FROM clause does not contain the [items] table. INNER JOIN your [items] table with the inserted table.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -