title: Stored Procedure with two input params and multiple matches and create view with in
body: <p>I am not much strong in SQL, so looking for some help.</p>
  
  <p>First I am looking for suggestion for the best way to implement this logic in SQL and then some sample code to implement.</p>
  
  <p>My portal is going to connect Students and Training Providers. </p>
  
  <p>Students: Select what courses (multiple) they want, type of delivery (online, class room), Industry(domain) to which the course to be targeted more, Location Preference.</p>
  
  <p>Training Providers: Select what courses offering (so one record for each course), offering locations, type of delivery for each course, industries (multiple) it is targeting.</p>
  
  <p>When student login:
  I would like to create SP which in turn create view to store the matched records of the Training Providers data which matches that student needs of that StudentID, CourseID passed to SP </p>
  
  <p>I have created the following sp ( but not included create view part as I am not sure how to do this)</p>
  
  <pre><code>set ANSI_NULLS ON
  set QUOTED_IDENTIFIER ON
  go
  
  ALTER PROCEDURE [dbo].[sp_TPsMatched2StuCourse]
      -- Add the parameters for the stored procedure here
  @StuID int,
  @CourseID int
  
  AS
  BEGIN
      Select TP.MemID,TP.PastExp,SN.DeliveryType,SN.LocPref,SN.Industry,SC.CourseID from 
  tbl_TrainingProvider as TP , tbl_StuCourses as SC, tbl_StuNeeds SN
  where SN.CourseID = @CourseID and SN.StuID = @StuID and
  SN.DeliveryType in (TP.DeliveryMode) and 
  SN.LocPref IN (TP.LocOffering) and
  SN.Industry IN (TP.Industries)
  
  END
  
  ---   exec sp_ELsMatched2EntProp 1, 1
  </code></pre>
  
  <p>Why I need to put the data is as follows:</p>
  
  <p>Assume the data is stored in that dynamic view and that would be bind to datagrid. Student then select interested TPs. Then only contact details would be shared to each other and this cannot be reveresed. So I would put this interested data in another table later. Every time data changes, hence the matches. Student can change some of his/her needs or new TPs join etc so view to be temparory.</p>
  
  <p>when I executed this using above command, I am not getting data though it matches few records. What is wrong I am doing. </p>
  
  <p>Any help would be greatly appreciated.</p>