i have got an error when i execute an internal representation of the XML document.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sureshrajiv
    New Member
    • Apr 2011
    • 2

    i have got an error when i execute an internal representation of the XML document.

    Declare @xmlDoc nvarchar(100)
    Declare @handle int
    SET @xmlDoc = N'
    <students>
    <StudentID> 100-252-1658</StudentID>
    <StudentFName>S uresh</StudentFName>
    <StudentLName>P rabhu</StudentLName>
    </students>'

    EXEC sp_xml_prepared ocument @handle OUTPUT, @xmlDoc

    If i execute bold statement i am getting an error called
    Msg 137, Level 15, State 2, Line 1
    Must declare the scalar variable "@idoc".
  • Sureshrajiv
    New Member
    • Apr 2011
    • 2

    #2
    jhkljhlgvkghccd fhdfbhdfhghfdfh dfgsdfgdfgdfgdf gdfgdfgdf

    Comment

    • deepuv04
      Recognized Expert New Member
      • Nov 2007
      • 227

      #3
      try the following

      Code:
      create procedure xmlread
       @xmlDoc text = ''
      as
      begin
      	 --nvarchar(100)
      	Declare @handle int
      	SET @xmlDoc = N'
      	<students>
      	<StudentID> 100-252-1658</StudentID>
      	<StudentFName>Suresh</StudentFName>
      	<StudentLName>Prabhu</StudentLName>
      	</students>'
      
      	EXEC sp_xml_preparedocument @handle OUTPUT, @xmlDoc
      
      	SELECT  *
      	FROM	OpenXML(@handle,'students', 1)    
      			WITH (StudentID varchar(50) 'StudentID[1]',
      				  StudentFName varchar(50) 'StudentFName[1]',
      				  StudentLName varchar(100) 'StudentLName[1]') 
      end

      Comment

      Working...