Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Set Column Equal to Value
    text
    copied!<p>I have the following query. I need <code>Description</code> to be set to the value of the long statement in the middle - the part beginning with <code>CONVERT</code> and ending with <code>[Description]</code>. The query I have now runs but the value of <code>Description</code> in the result is always NULL. Any ideas?</p> <pre><code>select s.SectionId, s.Academic_Year [AcademicYear], s.Academic_Term [AcademicTerm], s.Academic_Session [AcademicSession], s.Event_Id [EventId], s.Event_Sub_Type [EventSubType], s.Section [Section], s.Event_Long_Name [EventLongName], e.Description [EventDescription], CONVERT(varchar(MAX), S.DESCRIPTION) + '&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.bkstr.com/webapp/wcs/stores/servlet/booklookServlet?bookstore_id-1=044&amp;term_id-1=' + CASE S.ACADEMIC_TERM WHEN 'SPRING' THEN 'SPRING' WHEN 'SUMMER' THEN 'SUM' WHEN 'FALL' THEN 'FALL' WHEN 'J TERM' THEN 'J TERM' ELSE 'ADV' END + S.ACADEMIC_YEAR + '/' + CASE S.ACADEMIC_SESSION WHEN '01' THEN '1' WHEN '02' THEN '2' WHEN '03' THEN '3' END + '&amp;div-1=HILB&amp;dept-1=' + SUBSTRING(S.EVENT_ID, 1, CHARINDEX(' ', S.EVENT_ID) - 1) + '&amp;course-1=' + SUBSTRING(S.EVENT_ID, CHARINDEX(' ', S.EVENT_ID) + 1, LEN(S.EVENT_ID)) + '&amp;section-1=' + CONVERT(varchar(2), S.SECTION) + '" target=' + '"_blank"&gt;View Book Information&lt;/a&gt;' [Description], cest.Medium_Desc [SubTypeDescription], s.Credits [Credits], cge.Medium_Desc [GeneralEd], s.Start_Date [StartDate], s.End_Date [EndDate], s.Max_Participant [MaximumParticipants], s.Adds [AddCount], s.Wait_List [WaitlistCount], s.Sec_Enroll_Status [EnrollmentStatus], o.Org_Name_1 [CampusName], cp.Medium_Desc [ProgramDescription], cc.Medium_Desc [CollegeDescription], cd.Medium_Desc [DepartmentDescription], ccm.Medium_Desc [CurriculumDescription], ccl.Medium_Desc [ClassLevelDescription], nt.Nontrad_Med_Name [NonTraditionalDescription], cpn.Medium_Desc [PopulationDescription], case s.Other_Org when 'N' then 0 else s.Other_Org_Part end as [CampusOtherLimit], case s.Other_Program when 'N' then 0 else s.Other_Program_Part end as [ProgramOtherLimit], case s.Other_College when 'N' then 0 else s.Other_College_Part end as [CollegeOtherLimit], case s.Other_Department when 'N' then 0 else s.Other_Dept_Part end as [DepartmentOtherLimit], case s.Other_Curriculum when 'N' then 0 else s.Other_Curric_Part end as [CurriculumOtherLimit], case s.Other_Class_Level when 'N' then 0 else s.Other_CLevel_Part end as [ClassLevelOtherLimit], case s.Other_NonTrad when 'N' then 0 else s.Other_NonTrad_Part end as [NonTraditionalOtherLimit], case s.Other_Population when 'N' then 0 else s.Other_Pop_Part end as [PopulationOtherLimit], s.Other_Org_Add as [CampusOtherRegistered], s.Other_Program_Add as [ProgramOtherRegistered], s.Other_College_Add as [CollegeOtherRegistered], s.Other_Dept_Add as [DepartmentOtherRegistered], s.Other_Curr_Add as [CurriculumOtherRegistered], s.Other_CLevel_Add as [ClassLevelOtherRegistered], s.Other_Nontrad_Add as [NonTraditionalOtherRegistered], s.Other_Pop_Add as [PopulationOtherRegistered], case s.Registration_Type when 'TRAD' then 0 else 1 end as [IsConEd], cat.Medium_Desc [TermDescription], cas.Medium_Desc [SessionDescription], s.Credit_Type [DefaultCreditType], cct.Medium_Desc [CreditTypeDescription] from sections s left join code_eventsubtype cest on cest.code_value_key = s.event_sub_type left join code_generaled cge on cge.code_value_key = s.general_ed left join event e on e.event_id = s.event_id left join organization o on o.org_code_id = s.org_code_id left join code_program cp on cp.code_value_key = s.program left join code_college cc on cc.code_value_key = s.college left join code_department cd on cd.code_value_key = s.department left join code_curriculum ccm on ccm.code_value_key = s.curriculum left join code_classlevel ccl on ccl.code_value_key = s.class_level left join nontraditional nt on nt.nontrad_program = s.nontrad_program left join code_population cpn on cpn.code_value_key = s.population left join code_acaterm cat on cat.code_value_key = s.academic_term left join code_acasession cas on cas.code_value_key = s.academic_session left join code_acacredittype cct on cct.code_value_key = s.credit_type </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload