whats wrong with this trigger
create
trigger formatbilllocation on airtelperiod after insert
as
begin
declare
@filelocation varchar(max)
set
@filelocation=(select filelocation from inserted)
set
@filelocation='\\10.6.14.63\Airtel_Bills\'+@filelocation
update
airtelperiod set filelocation=@filelocation where airtelperiodid=inserted.airtelperiodid
end
its giving error "The multi-part identifier "inserted.airtelperiodid" could not be bound.
"
Answers
- Try now
create trigger formatbilllocation on airtelperiod after insert as begin declare @filelocation varchar(max) set @filelocation=(select filelocation from inserted) set @filelocation='\\10.6.14.63\Airtel_Bills\'+@filelocation update airtelperiod set filelocation=@filelocation from airtelperiod join inserted on airtelperiod.airtelperiodid=inserted.airtelperiodid end
Abdallah, PMP, MCTS- Marked As Answer byPhil BrammerMVP, ModeratorWednesday, November 04, 2009 1:42 PM
All Replies
- MY INTENTION IS TO APPEND STRING \\10.6.14.63\Airtel_Bills\ TO THE NEWLY INSERTED VALUE
- You need to join airtelperiod table with inserted. Something like this
create trigger formatbilllocation on airtelperiod after insert as begin declare @filelocation varchar(max) set @filelocation=(select filelocation from inserted) set @filelocation='\\10.6.14.63\Airtel_Bills\'+@filelocation update airtelperiod set filelocation=@filelocation from airtelperiod join inserted on airtelperiodid=inserted.airtelperiodid end
Abdallah, PMP, MCTS You need to join airtelperiod table with inserted. Something like this
create trigger formatbilllocation on airtelperiod after insert as begin declare @filelocation varchar(max) set @filelocation=(select filelocation from inserted) set @filelocation='\\10.6.14.63\Airtel_Bills\'+@filelocation update airtelperiod set filelocation=@filelocation from airtelperiod join inserted on airtelperiodid=inserted.airtelperiodid end
Abdallah, PMP, MCTS
nEW ERROR IS COMING AS "Ambiguous column name 'airtelperiodid'."
- Try now
create trigger formatbilllocation on airtelperiod after insert as begin declare @filelocation varchar(max) set @filelocation=(select filelocation from inserted) set @filelocation='\\10.6.14.63\Airtel_Bills\'+@filelocation update airtelperiod set filelocation=@filelocation from airtelperiod join inserted on airtelperiod.airtelperiodid=inserted.airtelperiodid end
Abdallah, PMP, MCTS- Marked As Answer byPhil BrammerMVP, ModeratorWednesday, November 04, 2009 1:42 PM
Try now
create trigger formatbilllocation on airtelperiod after insert as begin declare @filelocation varchar(max) set @filelocation=(select filelocation from inserted) set @filelocation='\\10.6.14.63\Airtel_Bills\'+@filelocation update airtelperiod set filelocation=@filelocation from airtelperiod join inserted on airtelperiod.airtelperiodid=inserted.airtelperiodid end
Abdallah, PMP, MCTS
THANKS A TON!!


