With the error below in mind - any idea how I might optimize the code below?
The column name 'MyXmlColumn' is specified more than once in the SET clause. A column cannot be assigned more than one value in the same SET clause. Modify the SET clause to make sure that a column is updated only once. If the SET clause updates columns of a view, then the column name 'MyXmlColumn' may appear twice in the view definition.
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''play'']/text())[1] with "false"')
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''eat'']/text())[1] with "false"')
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''work'']/text())[1] with "false"')
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''kill'']/text())[1] with "false"')
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''wash'']/text())[1] with "false"')
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''home'']/text())[1] with "false"')
UPDATE #tempTable
SET MBO.modify('replace value of (/*[local-name()=''configuration'']/*[local-name()=''sleep'']/text())[1] with "true"'),
ToPayment = 1
Here is the soultion: Here is the solution:: CREATE FUNCTION [dbo].[SBOObject]
(
-- Add the parameters for the function here
@var2 XML,
@var1 nvarchar(5),
@var3 nvarchar(5),
)
RETURNS XML
AS
BEGIN
SET @var2.modify('declare default element namespace "http://schemas.ObjectWorld"; replace value of (/configuration/sleep/text())[1] with sql:variable("@var1")')
SET @var2.modify('declare default element namespace "http://schemas.ObjectWorld"; replace value of (/configuration/work/text())[1] with sql:variable("@var3")')
RETURN @var2
END