Jump to content

Transfer SQL Data Results To Excel Sheet


Floetic

Recommended Posts

 

-- (1) Number of calls received for each priority of call [for a specified date range]

declare @startdate datetime,
@finishdate datetime

select RM.fldPriorityCode as 'Priority',
count(RM.fldRequestID) as 'Calls'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldRequestDate between '01-01-2007' and '03-05-2007'
and RM.fldRequestFlag like 'D'
group by RM.fldPriorityCode 
union
select 
'Total' as 'Priority',
count(RM.fldRequestID) as 'Calls'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldRequestDate between '01-01-2007' and '03-05-2007'
and RM.fldRequestFlag like 'D'
order by RM.fldPriorityCode asc


Results:

Priority	Calls		
1	20		
2	2912		
3	152		
4	571		
5	4		
Total	3659	

 

 

I would like to transfer these results to an excel sheet. For instance when the user opens up the excel worksheet and types in for a example a start date: 01-01-2007 and an end date: 03-05-2007 (into textboxes) then clicks a button say called 'Get stats' and then the results appear on the sheet.

 

 

How can this be done?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/51651-transfer-sql-data-results-to-excel-sheet/
Share on other sites

  • 2 weeks later...

in excell you have an option in 'data'->'import external data'->'new database query'

 

have a read on that, it is similiar to what one of my clients wanted to use, i basically formulated the query in excell and gave the client the excell file. When the file is opened, it will prompt for a database username and password (depending on how you set up the db connection in excell).

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.