Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 join queries

Author  Topic 

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2011-03-17 : 05:32:18
Hi all,

I want to join these two queries

1. SELECT ExamId,SubjectName,CourseId, ExamName,convert(varchar(11), ExamFromDate,109) ExamFromDate,convert(varchar(11), ExamToDate,109)ExamToDate FROM Exams WHERE Status='A' ORDER BY ExamName ASC
2. select T.CourseName from courses T inner join dbo.Split ((select CourseID from Exams),',') V on T.courseID = V.courseID

Tnx in advance

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2011-03-17 : 06:11:32
[code]
SELECT ExamId,SubjectName,E.CourseId, T.CourseName, ExamName,convert(varchar(11), ExamFromDate,109) ExamFromDate,convert(varchar(11), ExamToDate,109)ExamToDate
FROM Exams E
inner join courses T on E.CourseID = T.CourseID
inner join dbo.Split ((select CourseID from Exams),',') V on T.courseID = V.courseID
WHERE Status='A' ORDER BY ExamName ASC
[/code]


Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2011-03-17 : 06:40:52
It throws error
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '3,2' to data type int.

Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2011-03-17 : 07:34:12
Try converting your CourseID into varchar i.e. CONVERT(VARCHAR,CourseID) in your join statements happen
Go to Top of Page
   

- Advertisement -