Results 1 to 3 of 3
  1. #1
    Join Date
    May 2007
    Location
    Belfast, N.I
    Posts
    3

    Exclamation Unanswered: Transfer SQL Data Results To Excel Sheet

    Code:
    -- (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?

  2. #2
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    You could talk to an application developer about creating a report that would collect the dates and output the data in a grid, or talk to a dba or a developer about Reporting Services.

    -- This is all just a Figment of my Imagination --

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Create it as a stored procedure with parameters. I think Excel can link to a stored procedure as an external datasource.
    You're going to need some VB for Applications code on the Excel side...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •