Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

How to pass parameter for bigint field with multiple values seperated by comma .

I have a Field INVENTORYID with dataType bigint. I need to pass the value '99,100,101' as a parameter to query

SELECT INVENTORY_ID,QUANTITY FROM TRADE_INVENTORY WHERE INVENTORY_ID IN(@INVENTORYID)

Excecuting query I am getting an error as cannot cast varchar to bigint.

How to solve it.

Please Help me..

Thanks & Regards,

Vineetha.K.R
Posted

Here is an article that offers variety of methods:


http://www.sommarskog.se/arrays-in-sql-2005.html[^]
 
Share this answer
 
 
Share this answer
 
Hi,

Try this...

SQL
SELECT INVENTORY_ID,QUANTITY FROM TRADE_INVENTORY 
WHERE INVENTORY_ID IN(
                        SELECT * FROM split(@INVENTORYID,',')
                     )


You can get this Split Function[^] here.


Hope this will help you.


Cheers
 
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