Try this instead, see if it's any faster:
SET NOCOUNT ON;
IF OBJECT_ID(N'tempdb..#output') IS NOT NULL
DROP TABLE #output;
CREATE TABLE #output (line VARCHAR(255))
INSERT INTO #Output
VALUES ('<?xml version="1.0"?>'),
('<Objects>'),
(' <Object>'),
(' <Property Name="Folder">\\SERVER1\Clients\APHE\Accounts</Pr'),
('operty>'),
(' <Property Name="Access">Modify, Synchronize</Property>'),
(' <Property Name="User">Domain1\User3</Property>'),
(' </Object>'),
(' <Object>'),
(' <Property Name="Folder">\\SERVER1\Clients\APHE\Location</Property>'),
(' <Property Name="Access">Modify, Synchronize</Property>'),
(' <Property Name="User">Domain1\User3</Property>'),
(' </Object>'),
(' <Object>'),
(' <Property Name="Folder">\\SERVER1\Clients\BPE\Accounts</Pr'),
('operty>'),
(' <Property Name="Access">ReadAndExecute, Synchronize</Property>'),
(' <Property Name="User">Domain1\User2</Property>'),
(' </Object>'),
(' <Object>'),
(' <Property Name="Folder">\\SERVER1\Clients\BPE\Location</Pr'),
('operty>'),
(' <Property Name="Access">Modify, Synchronize</Property>'),
(' <Property Name="User">Domain1\User1</Property>'),
(' </Object>'),
(' <Object>'),
(' <Property Name="Folder">\\SERVER1\Clients\BPE\Comments</Pr'),
('operty>'),
(' <Property Name="Access">ReadAndExecute, Synchronize</Property>'),
(' <Property Name="User">Domain1\User2</Propert'),
('y>'),
(' </Object>'),
(' <Object>'),
(' <Property Name="Folder">\\SERVER1\Clients\PRD\Accounts</Pr'),
('operty>'),
(' <Property Name="Access">ReadAndExecute, Synchronize</Property>'),
(' <Property Name="User">Domain1\User3</Propert'),
('y>'),
(' </Object>'),
('</Objects>');
SELECT item.ref.value('(Property/text())[1]', 'nvarchar(200)') AS Folder,
item.ref.value('(Property/text())[2]', 'nvarchar(500)') AS Access,
item.ref.value('(Property/text())[3]', 'nvarchar(200)') AS UserGroup
FROM (SELECT CAST((SELECT '' + line
FROM #output
FOR XML PATH(''),
TYPE).value('.[1]', 'varchar(max)') AS XML) AS FormattedXML)
AS Sub
CROSS APPLY FormattedXML.nodes('/Objects/Object') AS item (ref);
Ignore the part that constructs the test data, of course. It's just the final query that matters.
It uses a For XML Path trick that concatenates strings together. It's documented behavior, and nicely replaces the cursor.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon