W kursorze musisz ponownie uruchomić swój plik xml , z deklaracją wyjścia xml.
DECLARE @id VARCHAR(25)
declare @loc varchar(25)
set @loc = '/MainItem/SubItem';
declare @query varchar(max)
DECLARE myCursor CURSOR LOCAL FAST_FORWARD FOR
SELECT * FROM @tempcolumnname
OPEN myCursor
FETCH NEXT FROM myCursor INTO @id
WHILE @@FETCH_STATUS = 0
BEGIN
set @query = 'DECLARE @hdoc INT;
EXEC sp_xml_preparedocument @hdoc OUTPUT,'''+ @info+'''
Select Statement
Insert Statement exec (@query)
FETCH NEXT FROM myCursor INTO @id
END
CLOSE myCursor
DEALLOCATE myCursor