Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Please help me

Conversion failed when converting the varchar value '2,15,19,20,21,22,23,24,25,26' to data type int.

when i change the field type int to varchar then no record no error show.
i try it manually when i type the (2,15,19,20,21,22,23,24,25,26) list then show the record fine. But when I pass this value list by the 'variable' then show the error "Conversion failed when converting the varchar value to data type int."

Please help me sir

https://ibb.co/iarjup
https://ibb.co/gGDfZp

What I have tried:

Alter Proc [dbo].[P_getPurchaseInvDetByID]               
--@Sdate date,                  
--@EDate Date,              
@purinvid varchar(50) ,
@itemidlist_pr varchar(500)


begin         
	Select id.purinvid,id.slno,i.itemnm ,i.itmcod,i.itmdescription,h.hsnnumber,    
	id.PDQty,id.PDMRP,id.PDRate,id.PDdis,id.pdcgst,id.cgstamt,id.pdsgst,id.sgstamt,    
	id.pdigst,id.igstamt,id.TaxableAmt,id.totaltaxamt,id.PDAmount,id.ItemIDpur,id.itemhsnid ,c.catnm,sc.subcatnm            
              
	from tbl_pur_invdet as id                
                
	INNER JOIN tbl_item     AS i   ON id.itemIDpur  =i.itemid                
	INNER JOIN tbl_HSN_Master  AS h   ON id.itemhsnid  = h.HsnId           
	INNER JOIN tblcat  AS c   ON c.catid=i.ITMcatid  
	INNER JOIN tblsubcat  AS sc   ON sc.subcatid=i.ITMsubcatid  
	where purinvid=@purinvid  and id.ItemIDpur in (CAST((@itemidlist_pr) AS INT))--('2','15','19','20','21','22','23','24','25','26') --(@itemidlist_pr)
	 order by id.slno    
end
Posted
Updated 12-Sep-18 0:58am
v3
Comments
Jayanta Modak 16-Sep-18 1:22am    
thanks sir

it is work fine thanks

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