DECLARE @ids table(id uniqueidentifier)
INSERT INTO @ids (id)
SELECT [edf_ID] FROM [EF_DraftForm] where [edf_Name] = '2019: Ochrona zabytków'
SELECT id FROM @ids
DECLARE @counter int
SET @counter = (SELECT COUNT(id) FROM @ids)
DECLARE @id uniqueidentifier
WHILE (@counter > 0)
BEGIN
SET @id = (SELECT TOP 1 id FROM @ids)
DECLARE @xml XML
SET @xml = (SELECT cast([edf_Xml] as XML) FROM [dbo].[EF_DraftForm] where [edf_ID] = @id)
SET @xml.modify('declare namespace my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-05-28T08:49:34";
replace value of (my:OchronaZabytkow/my:OtrzymaneDofinansowania/my:PageTitle/text())[1]
with "VII. Nazwy zadań oraz wysokość przyznanego dofinansowania ze środków pozostających w dyspozycji ministra w roku 2018"')
UPDATE EF_DraftForm
SET edf_Xml = cast(cast(@xml as varchar(max)) as ntext)
where [edf_ID] = @id
DELETE FROM @ids
WHERE id = @id
SET @counter = (SELECT COUNT(id) FROM @ids)
END