Why do I receive a Mutator error when modifying an Xml value in Sql

前端 未结 1 792
刺人心
刺人心 2020-12-22 07:19

I have the following stored procedure:

ALTER PROCEDURE [dbo].[UpPro]
(
    @PN varchar(200),
    @xml xml,
    @gVa varchar(10),
)
AS
/* update the gender */         


        
相关标签:
1条回答
  • 2020-12-22 08:00

    The error actually says it all, @XML is null and that is not allowed.

    Repro:

    declare @X xml;
    
    set @X.modify('replace value of text()[1] with "1"');
    

    Msg 5302, Level 16, State 1, Line 4 Mutator 'modify()' on '@X' cannot be called on a null value.

    Check for null before you modfy.

    declare @X xml;
    
    if @X is not null
      set @X.modify('replace value of text()[1] with "1"');
    
    0 讨论(0)
提交回复
热议问题