IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[workss]') AND type = 'P')
DROP PROCEDURE [dbo].[workss]
GO

CREATE proc workss
as
declare @id int
declare @value nvarchar(1000)
create table #temp(
id int,
value nvarchar(1000),
result nvarchar(500),
result1 nvarchar(500),
result2 nvarchar(500)
)
create table #temp1
(
id int,
result nvarchar(500),
result1 nvarchar(500),
result2 nvarchar(500)
)
insert into #temp(id,value)select distinct ord_xcmxord2id,[ord_photos]=stuff((select  '|'+ord_photos from order_91 t where ord_xcmxord2id=order_91.ord_xcmxord2id and ord_photos!='' for xml path('')), 1, 1, '') 
from order_91
declare works_cursor cursor scroll for select id,value from #temp
open works_cursor

fetch next from works_cursor into @id,@value
While @@Fetch_Status= 0

begin

insert into #temp1 select top 1 id,Result1,Result1,Result2 from StrToTable(@id,@value,'|')

fetch next from works_cursor into @id,@value

end
update a set a.result=b.Result ,a.result1=b.result1,a.result2=b.result2 from #temp a,#temp1 b where b.id=a.id
select * from #temp1
close works_cursor
deallocate works_cursor
drop table #temp
drop table #temp1