?
Solved

Exporting Data

Posted on 1998-12-22
2
Medium Priority
?
184 Views
Last Modified: 2010-03-19
This query works fine when I run it in the query analyzer:

DECLARE @mo_start datetime,
        @mo_end   datetime

SET @mo_start = '10/01/1998'
SET @mo_end = '10/31/1998'

SELECT *
   FROM ORG_EPISODES AS e INNER JOIN ORG_TIME_PERIODS AS t
      ON e.PERIOD_ID = t.PERIOD_ID
      AND t.PERIOD_START BETWEEN @mo_start AND @mo_end

Since I need to export the results of the query to an Excel spreadsheet I used the Data Transformation Services wizard to set up this process and have it using this query.  

I get an error when it executes because it builds a results table and tries to dump all the field names from both tables into it; both tables have a field called PERIOD_ID (that's what I joined on)and SQL is rejecting the process on the basis of results having 2 fields named PERIOD_ID.  Renaming one of the fields is not a viable option because it's someone else's database and the conflict only is occurring because SQL is building an intermediary table and populating it with the fields from both tables, when the "run" query only has the values from one table.  

Does anyone have any idea how to get around this and get my query result out to Excel?

Also, if I continue with the Data Transformation Services how can I set up the dates as global variables which can be changed each month when the user runs this.  I saw a "holding" place for this under properties for the local Data Transformation Package - but don't know how to work with this.  
0
Comment
Question by:scarlett
[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 2

Accepted Solution

by:
tschill120198 earned 140 total points
ID: 1092359
Instead of using "SELECT *" you could explicitly list the column names each column of the result set... you don't really both period_id, anyway, right?

    select e.Period_ID,
           t.Period_Start,
           ...
    from   .....

0
 

Author Comment

by:scarlett
ID: 1092360
Thanks - I didn't need a join - I needed a nested query - didn't realize that I was getting duplicates.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.
Suggested Courses

762 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