troubleshooting Question

SQL Server SQL Query Excluding Specific Field Values (Efficienct Code)

Avatar of eeyo
eeyo asked on
Microsoft SQL ServerVisual Basic.NETSQL
11 Comments2 Solutions118 ViewsLast Modified:
Using  VB.NET Winforms application:  Essentially, I would like to generate a list of GUIDS to exclude from a query (anywhere from about 10 to 1000 GUIDS).  I am looking to determine which of these is most efficient.  Assuming that I have read-only access, can run SQL query code (but not create stored procedures).  

1)  Dynamically create a SQL WHERE clause to exclude the GUIDS (e.g. "WHERE field1 is NOT IN ('GUID1', 'GUID2", etc...)"
2) Create temporary table in SQL, load the excluded GUIDS, then run the final query against standard tables JOINed with this temporary table
3) Other?
Nitin Sontakke

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros