title: inserting multiple rows through stored proc using XML
body: <p>I am trying following stored proc to insert attendance of whole class(multiple student) at one go.</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[usp_add_attendanceByLectureId] 
      -- Add the parameters for the stored procedure here
      @pLectureId int,
      @pUsersXml xml  
  AS
  BEGIN
     --SET NOCOUNT ON;
  
      INSERT INTO AcademicAttendance(StudentId, LectureId, [Status])      
      select M.Item.value('StudentId[1]','INT') as StudentId, -- here error occured
      @pLectureId as LectureId,
      M.Item.value('Status','BIT') as [Status]
      FROM @pUsersXml.nodes('/ArrayOfStudnts/Student') AS M(Item)
  
  END
  </code></pre>
  
  <p>While creating above sp following error occured</p>
  
  <p>Msg 2389, Level 16, State 1, Procedure usp_add_attendanceByLectureId, Line 17
  XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'</p>