Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Simple Query Automation

Author  Topic 

wbach3
Starting Member

3 Posts

Posted - 2011-12-20 : 17:56:01
Hi all! I am recently retiring my DTS skills for SSIS and I need help figuring out how to make this simple query run and show up in an excel sheet.


SELECT TOP 5 *
INTO #a
FROM Player

SELECT PlayerID, Line1, Line2, City, State
INTO #b
FROM PlayerAddress
WHERE PlayerID IN (SELECT PlayerID FROM #a)


Now heres the fun part I can only use temp tables. Id like the results from #b to be delieverd to the excel sheet. This used to take me all of 30 seconds in DTS and now im lost. Thanks for your help.

Bill

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-12-20 : 18:06:28
quote:
Now heres the fun part I can only use temp tables
Why? This does the same thing:

SELECT PlayerID, Line1, Line2, City, State
FROM PlayerAddress
WHERE PlayerID IN (SELECT TOP 5 PlayerID FROM Player)


By the way, TOP is meaningless without an ORDER BY clause. You could get different results on different runs without it.
Go to Top of Page

wbach3
Starting Member

3 Posts

Posted - 2011-12-20 : 19:00:47
This is just a simple example. The query itself has many staging tables involved. I was thinking that if i could understand how to run a simple one the same rules apply. Basically how do i

1) Run a sql statment with multiple temp tables
2) export the temp table results to an excel sheet for distribution

Thanks
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-12-20 : 19:44:51
Without more details, I'd recommend putting as much logic into a stored procedure as possible and then using that as the source in SSIS. You may need to use an Execute SQL Task but I'm not sure whether that can pipe results to a destination (I'm not an SSIS guru). The stored procedure should have a final SELECT statement that gives you the results you need.
Go to Top of Page
   

- Advertisement -