我执行以下存储过程。但是它显示了错误。错误是
'。'附近的语法不正确。即在'xmlFields.Country'中显示错误
请也查看此存储过程,并提前帮助我,谢谢

create procedure sp_SuUpdateSUADUsersStatus
(
    @FinalEMPCode nvarchar(50),
    @xmlFields NTEXT
)
AS
DECLARE @CityIDReturn INT
SET NOCOUNT ON
BEGIN
 DECLARE @hdoc INT

 EXEC sp_xml_preparedocument @hdoc OUTPUT, @xmlFields

          BEGIN
         EXEC @CityIDReturn=sp_SuSaveADUsersLocation @Country=xmlFields.Country,
          xmlFields.State,xmlFields.City
         FROM OPENXML(@hDoc, 'EmpCode/User', 2)   WITH
         (Country nvarchar(500),State nvarchar(500),City nvarchar(500))
         as xmlFields
         where xmlFields.Country <>'' and xmlFields.State <>'' and xmlFields.City
                 <>'')
      END



    EXEC sp_xml_removedocument @hdoc


End

最佳答案

您不能这样做@Country=xmlFields.Country

尝试下面的代码

  EXEC @CityIDReturn=sp_SuSaveADUsersLocation xmlFields.Country,
          xmlFields.State,xmlFields.City


如果要执行每个记录的过程,则无法执行这样的过程,请使用sql游标来实现

10-08 06:49