?
Solved

SQL Server (Update A Query from External File)

Posted on 2013-06-21
2
Medium Priority
?
501 Views
Last Modified: 2013-06-22
Below I have a SQL Server Query where I am looking to return the Customer Name and Address for the specified CustomerID's.  
I have to run this query on a regular basis.  However,  each time I run this I have to insert a long list of customer ID's into the query from an Excel spreadsheet.  It's get to be time consuming as the list of CustomID's changes each time I need to run this query.  I am looking for method where I can speed things up or automate the process of pointing the query at this list of customerID's that are stored in the Excel Spreadsheet. Thanks for any feedback.
--Query
Select CustomerName, Address
from Customers
WHERE CustomerID in ('12345', 12346', '12347')
0
Comment
Question by:fjkaykr11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 39267268
I'd consider ...

building a table to hold these ID's
Build an ETL or BULK INSERT to delete all from the table, then import the ID's from the Excel spreadsheet into that table.  Then  
Change the query so that it JOINS on the new table, like...

Select CustomerName, Address
from Customers
   JOIN YourNewTable ON Customers.CustomID = YourNewTable.CustomID

Open in new window

0
 
LVL 3

Author Closing Comment

by:fjkaykr11
ID: 39268782
thanks appreciate the info.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

752 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