Solved

Store Procedure

Posted on 2009-05-18
4
151 Views
Last Modified: 2012-05-07
I have a procedure that needs some adjustment..can someone help me please?

I have 2 tables: Survey Table and EvaluationVisit

depends on the particpant ID I need to display this table:


Particpant ID      Date of Evaluation      Evaluation Type      School Name      Age      Gender       
1             05/12/2009            begin                              
1            05/13/2009            end                                    

All the time I create a Evaluation visit I need to have this displayed in this table indepentend if I have a Survey school Name, Age or Gender created..

Right now all my procedure does is bring the data if there is aSurvey and Evaluation with the same a participantID

here is my procedure:

ALTER  PROCEDURE sp_GetAllEvaluationVisit(

	@ParticipantID as int) AS
 
 

BEGIN
 

 SET NOCOUNT ON

--declare @ParticipantID as int

--set  @ParticipantID = '1'
 
 

Select
 
 

e.ParticipantID as [ParticipantID], e.DateEvaluation as [DateEvaluation], 
 

(case   when (e.EvaluationID = 0) then ''

	when (e.EvaluationID = 1) then 'Program Begin'

        when (e.EvaluationID = 2) then 'Program End'

	when (e.EvaluationID = 3) then 'Six Month'

end ) as [EvaluationType],
 
 

(case   when (s.SchoolID = 0) then ''

	when (s.SchoolID = 1) then 'Santee Educational Complex'

        when (s.SchoolID = 2) then 'Jefferson'

	when (s.SchoolID = 3) then 'Dorsey'

	when (s.SchoolID = 4) then 'Fremont'

	when (s.SchoolID = 5) then 'West Adams'

end ) as [SchoolName],
 
 

s.Age as [Age],
 

(case   when (s.Gender = 1) then 'Male'

        when (s.Gender = 2) then 'Female'

end ) as [Gender]
 
 

from tbl_EvaluationVisit e  join tbl_Survey s on   e.ParticipantID = @ParticipantID and s.ParticipantID = @ParticipantID

Open in new window

0
Comment
Question by:Romacali
  • 2
  • 2
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24414804
change:
from tbl_EvaluationVisit e  join tbl_Survey s on   e.ParticipantID = @ParticipantID and s.ParticipantID = @ParticipantID

into:
from tbl_EvaluationVisit e  
left tbl_Survey s
  on s.ParticipantID = e.ParticipantID
where e.ParticipantID = @ParticipantID
0
 

Author Comment

by:Romacali
ID: 24414886
I got this:
Server: Msg 155, Level 15, State 1, Line 33
'tbl_Survey' is not a recognized join option.
0
 

Author Comment

by:Romacali
ID: 24414933
I added join in front of left and it works.. Is it ok to have join there?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24416015
oups, forgot the join indeed :....
glad I could help
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQl Agent job fails--SSIS package looses password 6 45
Updating statistics with error notification email in SQL server 4 71
CROSS APPLY 4 43
Sql query 107 24
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now