Stored Procedure question

Results 1 to 2 of 2

Thread: Stored Procedure question

  1. #1
    Join Date
    Dec 1969

    Default Stored Procedure question

    CREATE PROCEDURE get_people <BR> @GroupID numeric(9) <BR>AS <BR><BR>SELECT People.PeopleID, <BR> People.Email, <BR> People.Firstname, <BR> People.Lastname, <BR> Types.TypeID, <BR> Types.Type, <BR> Status.Date, <BR> Status.ID, <BR> Org.Orgname, <BR> Area.ID <BR><BR>FROM People <BR> JOIN Status ON (Status.ID = People.PeopleID) <BR> JOIN Groups ON (Groups.PeopleID = Status.PeopleID) <BR> JOIN Types ON (Types.TypeID = Status.StatusTypeID) <BR> JOIN Org ON (Org.OrgID = Types.OrgID) <BR> JOIN Area ON (Area.PeopleID = People.PeopleID) <BR><BR>WHERE (DATEDIFF(day,getdate(),Status.ExDate)&#062;=0) <BR> AND Groups.GroupsID = @GroupID <BR><BR>ORDER BY People.Lastname, People.PeopleID, Status.OrgID ASC <BR><BR><BR>The line I want to insert is in the WHERE clause. I need it to limit the selection based on a request from a form which will be put into the querystring. <BR><BR>WHERE (DATEDIFF(day,getdate(),Status.ExDate)&#062;=0) <BR> AND Groups.GroupsID = @GroupID <BR> AND People.Lastname LIKE &#039;" & Request("letter") & "&#039; <BR><BR>I dont think that the second "AND" is written properly. If I dont have it there the procedure works like a charm, I just want to limit it&#039;s results more. Any help would be greatly appreciated, thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: Stored Procedure question

    Try changing the JOIN line for Groups to:<BR><BR>JOIN Groups ON (Groups.PeopleID = Status.PeopleID) AND (Groups.GroupID = @GroupID)<BR><BR>That might help

Posting Permissions

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