Solved

VB.net SQL statement where column is  any of an item in a list

Posted on 2014-02-12
2
325 Views
Last Modified: 2014-02-12
Hi
I have a variable in VB.net that contains a list of string items separated by commas
eg "Canada,USA,Australia"
How do I build a SQL Where clause to brings up anything in this list?
0
Comment
Question by:murbro
2 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
Comment Utility
you can add quotes and use the IN clause:

sql = "select * from YourTable where country in ('" + YourVariable.Replace(",", "','") + "')"
0
 

Author Closing Comment

by:murbro
Comment Utility
Thanks very much
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now