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
 Error when running query

Author  Topic 

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-03-11 : 22:08:00
I have the Conversion failed when converting from a character string to uniqueidentifier.

select W.ModuleTitle,
W.ModuleCode, W.Term, W.studentID,
stuff ( (Select ', ' + (Case when at.Status = '0' then convert(varchar(50), at.DateAbsent, 106) + '*'
when at.Status = 'M' then convert(varchar(50), at.DateAbsent, 106) + '**' end)
from AttendanceWarning aw, AttendanceTable at
where w.WarningLetteRId = aw.WarningLetterId
and at.attendanceId = aw.AttendanceId
for xml path(''))
,1,1,'') as Date
from WarningLetter w

The problem is aw.WarningLetterId are varchar(50), and aw.AttendanceId are also varchar(50) wehere the PK w.WarningLetteRid and at.attendanceId are uniqueidentifier.

I could not covert the aw.WarningLetterId and aw.AttendanceId without deleting all the old results :( Please do you have any solutions?


check out my blog at http://www.aquariumlore.blogspot.com

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-03-11 : 22:22:42
Talk about being an idiot. I am so sorry, I asked for help and keep trying when I suddenly hit upon a solution

the solution is to convert to varchar(50)
i.e. where convert(varchar(50), w.WarningLetteRId) = aw.WarningLetterId
and convert(varchar(50), at.AttendanceId = aw.WarningLetterId

but I don't understand why when I try to cast (aw.WarningLetterId as uniqueidentifier) result in the same error. Any enlightenment is very much appreciated

check out my blog at http://www.aquariumlore.blogspot.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-12 : 13:01:59
what are typical values in aw.WarningLetterId & aw.AttendanceId?
Go to Top of Page
   

- Advertisement -