Solved

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

Posted on 2014-02-12
2
327 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 70

Accepted Solution

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

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

Author Closing Comment

by:murbro
ID: 39852961
Thanks very much
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
T-SQL: Episode III - Revenge of The Dude 24 52
SSRS 2013 - Creating a summarized report 19 32
SSRS 2013 - Overlapping reports 2 19
sql select record as one long string 21 21
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

816 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

11 Experts available now in Live!

Get 1:1 Help Now