The argument 1 of the XML data type method “value” must be a string literal

前端 未结 2 1356
心在旅途
心在旅途 2020-12-06 10:56

How to change my T-SQL query so that this error doesn\'t occur:

\'The argument 1 of the XML data type method \"value\" must be a string literal.\'

2条回答
  •  無奈伤痛
    2020-12-06 11:12

    You must use sql variable implicitly:

    Declare @Count Int = 1
    While(@count <= @j)
    Begin
    insert into mytable
    ([Word])
    Select ([XmlColumn].value('(/word[sql:variable("@Count")]/@Entry)[1]','nvarchar(max)'))
        from OtherTable WHERE ID=2
    

提交回复
热议问题