I want to display the columns the MERGE statement below will create for the UPDATE & INSERT portion. In other words I want to see what it is about to update/insert.I tried using the Print function but keep getting syntax errors.Code:DECLARE @PrintMessage nvarchar(500);MERGE STUDENTPROGRAMS AS sp USING (Select sd.ChildID, sd.SchoolID, sd.SchoolYear, sd.Mobility, sd.DateIn, sd.DateOut, sd.DateOfEntry, sd.UserOfEntry, sd.DateOfChange, sd.UserOfChange ,st.TermStartDate, ,s2.TermEndDate AS YREndDate from StandardChildDemographics AS sd left join SchoolTerms AS st on sd.SchoolID = st.SchoolID and sd.SchoolYear = st.SchoolYear and st.TermNbr = 1 left join SchoolTerms AS s2 on sd.SchoolID = s2.SchoolID and sd.SchoolYear = s2.SchoolYear and s2.TermNbr = 4 where sd.DateOfChange >= dateadd(day,datediff(day,0,getdate())-20,0) and sd.SchoolYear = '2010-2011' and sd.Mobility = 'Y' ) AS i ON sp.SchoolYR = i.SchoolYear and sp.SID = i.ChildID and ((sp.ProgStrt_DT = i.TermStartDate) OR (sp.ProgStrt_DT = i.DateIn)) WHEN MATCHED THEN-- this is where I want to see all columns -- from both the row being updated & what the-- columns are going to be updated with.-- bascally display the columns hereUPDATE Set @PrintMessage = N'Update ' + i.SchoolYear + N' ' + (CAST(i.ChildID as nvarchar(11)) + (CAST(sp.ProgStrt_DT as char(11))); ;
OR is there a better way to see what is going to be executed?Thanks.