Results 1 to 4 of 4

Thread: Using Transform within Sp

  1. #1

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721

    Using Transform within Sp

    Hi

    Pls Help, I have this transform stmt within a Sp which I wish to use
    inorder to output the results similar to a crosstab qry...so my ? is can
    I use this code and if so why do I recieve an error

    Code:
    if @ReportType = 'MonthlyCounts'
    begin
    	TRANSFORM  count(CQuote_int)as Quotes
    	SELECT DateName(Month, ReportDate) Month
    	from #transactionstable
    	WHERE (DATEPart(YYYY, ReportDate) = DATEPart(YYYY, GetDate())
    	GROUP BY DateName(Month, ReportDate), datePart(MM,ReportDate)
    	ORDER BY order by datePart(MM,ReportDate)
    
    PIVOT transactionstable.Month;
    		
    	/*
    	select DateName(Month, ReportDate) Month, sum(CQuote_int)Quotes ,sum(CReferral_int)Referrals , sum(CNewBus_int) Policies  
    		from #transactionstable
    	where DATEPart(YYYY, ReportDate) = DATEPart(YYYY, GetDate())
    	group by DateName(Month, ReportDate), datePart(MM,ReportDate)
    	order by datePart(MM,ReportDate)
    	*/
    end
    The errors are
    Code:
    Server: Msg 170, Level 15, State 1, Procedure Tonyg_ReportChart_GetBDOnlineMonthlyCountsNew1, Line 123
    Line 123: Incorrect syntax near 'TRANSFORM'.
    Server: Msg 156, Level 15, State 1, Procedure Tonyg_ReportChart_GetBDOnlineMonthlyCountsNew1, Line 127
    Incorrect syntax near the keyword 'GROUP'
    Ta very much
    ** HOLLY **

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Using Transform within Sp

    You say you are using this statement in an SP, so i take it you are using SQL Server ???

    If so then you can't use the Transform Statement it doesn't exist in SQL Server it is an Access Specific statement
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  3. #3

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721

    Re: Using Transform within Sp

    Hi, Thanks for replying!! is there or do you know if this can be done in sql
    using any other stmt??

    ** HOLLY **

  4. #4
    Addicted Member
    Join Date
    Oct 2008
    Location
    Califorina
    Posts
    235

    Re: Using Transform within Sp

    Take a look at this.
    http://www.sqlteam.com/article/dynam...s-pivot-tables
    It's a pretty good example.

Posting Permissions

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



Click Here to Expand Forum to Full Width