Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0SPROC inner join problemSPROC inner join problem
Previous
 
Next
New Post
12/14/2006 9:32 AM
 
I'm migrating a exam module to DNN, but now I run into a problem with inner join statements.
the existing Stored Procedure is:

CREATE PROCEDURE Exam_getUsersOfExam
(
    @examId INT
)
AS

SELECT DISTINCT Users.UserID, Users.FirstName, Users.LastName, Departments.Name As GroupName
FROM Exam_ExamQuestion Inner Join (Exam_Result Inner Join (Users Inner Join Departments On Users.DepartmentId = Departments.DepartmentId) On Exam_Result.UserId = Users.UserID) On Exam_ExamQuestion.ExamQuestionId = Exam_Result.ExamQuestionId
WHERE Exam_ExamQuestion.ExamId = @examId
Order by Users.FirstName asc, Users.LastName asc

GO

now is my problem that my DNN installation hasn't got an department table, so I have to get rid off that part of the SPROC.

Can anyone help me with this problem?

Many thanks,
 
New Post
12/14/2006 12:11 PM
 

Try

CREATE PROCEDURE Exam_getUsersOfExam
@examId INT

AS
-- exec Exam_getUsersOfExam 10
SELECT DISTINCT 
  Users.UserID,
  Users.FirstName,
  Users.LastName
FROM
  Exam_ExamQuestion,
  Exam_Result,
  Users
WHERE
  Exam_ExamQuestion.ExamId = @examId
  and Exam_ExamQuestion.ExamQuestionId = Exam_Result.ExamQuestionId
  and Exam_Result.UserId = Users.UserID
Order by
  Users.FirstName asc,
  Users.LastName asc
GO

 

 
New Post
12/14/2006 1:11 PM
 

I really couldn't find a problem with your stored proc. It should work and typically not having a table available will generate a warning rather than an out right error. What error are you getting?

I also suggest trying to move the "on" statements next to their respective join. I also recommend formatting your queries as I have below, this allows for easier debugging because if you need to eliminate a join you can do so typically by placing "--" infront of the join you wish to eliminate by commenting it out.

CREATE PROCEDURE Exam_getUsersOfExam
(
    @examId INT
)
AS

SELECT DISTINCT Users.UserID, Users.FirstName, Users.LastName, Departments.Name As GroupName
FROM Exam_ExamQuestion 
     INNER JOIN Exam_Result ON Exam_ExamQuestion.ExamQuestionId = Exam_Result.ExamQuestionId 
     INNER JOIN Users ON Exam_Result.UserId = Users.UserID
     INNER JOIN Departments ON Users.DepartmentId = Departments.DepartmentId
WHERE Exam_ExamQuestion.ExamId = @examId
ORDER BY Users.FirstName ASC, Users.LastName ASC

GO

 
New Post
12/15/2006 7:37 AM
 
Thanx,

It's working fine now
 
New Post
12/15/2006 12:25 PM
 

Where is your departments table?  Is it in another database?  As long as it's on the same server, you can access that table using...

SELECT DISTINCT Users.UserID, Users.FirstName, Users.LastName, Departments.Name As GroupName
FROM Exam_ExamQuestion 
     INNER JOIN Exam_Result ON Exam_ExamQuestion.ExamQuestionId = Exam_Result.ExamQuestionId 
     INNER JOIN Users ON Exam_Result.UserId = Users.UserID
     INNER JOIN databasename.dbo.Departments ON Users.DepartmentId = Departments.DepartmentId
WHERE Exam_ExamQuestion.ExamId = @examId
ORDER BY Users.FirstName ASC, Users.LastName ASC

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0SPROC inner join problemSPROC inner join problem


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out