SQL Stored Procedure Problem

Results 1 to 2 of 2

Thread: SQL Stored Procedure Problem

  1. #1
    Greg Owen Guest

    Default SQL Stored Procedure Problem

    The SPROC:<BR><BR>CREATE PROCEDURE rpt_Section_Page<BR>(<BR>@dteStartDate datetime,<BR>@dteEndDate datetime<BR>)<BR>AS<BR>/*This SPROC takes in 2 variables (start date, end date) from the<BR>TrafficLogReport and returns the data to the app */<BR><BR>declare @TheSection varchar<BR>declare @TheCount int<BR>/*These are the 2 sets of data we return to the application*/<BR><BR>SELECT @TheSection = DISTINCT CURR_PAGE, @TheCount = COUNT(CURR_PAGE) <BR>FROM TRAFFIC_LOG<BR>WHERE VIEW_DATE &#062; @dteStartDate and VIEW_DATE &#060; @dteEndDate<BR>GROUP BY CURR_PAGE<BR>ORDER BY CURR_PAGE<BR><BR>SELECT @TheSection AS TheSection, @TheCount AS TheCount<BR><BR>THE ERROR MESSAGE WHEN CHECKING SYNTAX:<BR>Error 156: Incorrect Syntax near the keyword &#039;DISTINCT&#039;<BR><BR>The following works within Query Analyzer without a problem....<BR>SELECT Distinct CURR_PAGE AS [THE SECTION], COUNT(CURR_PAGE) AS [THE COUNT]<BR>FROM TRAFFIC_LOG<BR>WHERE VIEW_DATE &#062; &#039;03/01/2001&#039; and VIEW_DATE &#060; &#039;04/25/2001&#039;<BR>GROUP BY CURR_PAGE<BR>ORDER BY CURR_PAGE<BR><BR>Since The CORE Select statement works in Query Analyzer, I do not<BR>understand the problem I am having with the SPROC.

  2. #2
    Greg Owen Guest

    Default RE: SQL Stored Procedure Problem - NEVERMIND

    I did not need the DISTINCT because I was using the GROUP BY<BR>and also, I could move the DISTINCT in from of @TheSection<BR>and that would work too. Brain Fart!

Posting Permissions

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