Solved

SQL Server (Update A Query from External File)

Posted on 2013-06-21
2
484 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
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
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
Comment Utility
thanks appreciate the info.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sql Audit table 3 47
Analysis of table use 7 27
SQL Server 2008 R2 - Execution Plan 3 28
Auditing with Temporal Tables 4 16
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

16 Experts available now in Live!

Get 1:1 Help Now