Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Query like below

INSERT INTO iProc.TblContracItemDt
	(
		ClientId, ContractId, ItemId, ItemPkgId, IsOpenCont, OpenBasePrice, IsActive, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn, IsDelete
	) 
	OUTPUT INSERTED.ContItemDtId,INSERTED.ItemId,a.ItemLineNo INTO @ContracItemDtOutput 
	
	SELECT ClientId, @Pid, ItemId, ItemPkgId, IsOpenCont, OpenBasePrice, IsActive, CreatedBy, GETDATE() AS CreatedOn, ModifiedBy, GETDATE() AS ModifiedOn, IsDelete FROM @TVPContracItemDt a


when i executing the following error occur

Msg 4104, Level 16, State 1, Procedure Usp_TblContractInsert, Line 100 [Batch Start Line 7]
The multi-part identifier "a.ItemLineNo" could not be bound.


please help me to solve this

What I have tried:

I have tried to execute the query .
INSERT INTO iProc.TblContracItemDt
	(
		ClientId, ContractId, ItemId, ItemPkgId, IsOpenCont, OpenBasePrice, IsActive, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn, IsDelete
	) 
	OUTPUT INSERTED.ContItemDtId,INSERTED.ItemId,a.ItemLineNo INTO @ContracItemDtOutput 
	
	SELECT ClientId, @Pid, ItemId, ItemPkgId, IsOpenCont, OpenBasePrice, IsActive, CreatedBy, GETDATE() AS CreatedOn, ModifiedBy, GETDATE() AS ModifiedOn, IsDelete FROM @TVPContracItemDt a
but that error shows
Posted
Updated 18-Jul-18 5:39am
Comments
CHill60 28-Jun-18 8:11am    
You can't use columns from the SELECT, only from INSERTED. Because you are not inserting ItemLineNo into the table you can't reference it in the OUTPUT.

1 solution

Please remove a.Itemlineno from output inserted row. It will work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900