Colonne de reference de la requête de mise à jour principale dans la sous-requête

J'ai une table UserLOG (> 5M lignes) avec une colonne LOG_PARAMETERS qui contient une string Json et d'autres colonnes (que j'ai nommé LOG_param1 à LOG_param9 ici). J'utilise la fonction TSQL Phil Factor pour extraire les parameters du JSON et mettre à jour ma table.

Voici mon script de création de table:

 CREATE TABLE User_LOG( [LOG_Id] [int] IDENTITY(1,1) NOT NULL, [LOG_PARAMETERS] [nvarchar](500) NULL, [LOG_DATE] [varchar](25) NULL, [LOG_param1] [uniqueidentifier] NULL, [LOG_param2] [uniqueidentifier] NULL, [LOG_param3] [uniqueidentifier] NULL, [LOG_param4] [uniqueidentifier] NULL, [LOG_param5] [uniqueidentifier] NULL, [LOG_param6] [uniqueidentifier] NULL, [LOG_param7] [varchar](25) NULL, [LOG_param8] [int] NULL, [LOG_param9] [smallint] NULL, CONSTRAINT [PK_UserLOG] PRIMARY KEY CLUSTERED ([LOG_Id] ASC) ) 

Certaines données:

 INSERT INTO dbo.User_LOG ([LOG_PARAMETERS]) values ('{"LOG_param7": "2015-06-06T17:24:06.000Z", "LOG_param1": "04162673-90df-495f-9691-32c063b78e80", "LOG_param2": "2230f23e-83b6-46b8-aa81-fefce20efdf0", "LOG_param3": "7aa411a0-c265-4d8f-896a-4b2707c4086e"}'), ('{"LOG_param7": "2015-06-06T17:24:06.000Z", "LOG_param1": "04462673-90df-495f-9691-32c063b88e80", "LOG_param2": "2230f23e-85b6-46b8-aa81-fefce20efdf0", "LOG_param3": "7aa419a0-c265-4d8f-896a-4b2707c4086e"}'), ('{"LOG_param7": "2015-06-06T17:24:06.000Z", "LOG_param1": "04162673-90df-495f-9691-32c063b68e80", "LOG_param2": "2260f23e-83b6-46b8-ba81-fefce20efdf0", "LOG_param3": "7aa511a0-c265-4d8f-896a-4b2707c4086e"}'), ('{"LOG_param7": "2015-06-06T17:24:06.000Z", "LOG_param1": "04152673-90df-495f-9691-32c063b98e80", "LOG_param2": "2230f23e-82b6-46b8-va81-fefce20efdf0", "LOG_param3": "7aa411a0-c265-4d8f-893a-4b2707c4086e"}') 

J'essaie de mettre à jour cette table en utilisant la requête suivante:

 UPDATE User_LOG SET LOG_param1 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param1]) ,LOG_param2 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param2]) ,LOG_param3 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param3]) ,LOG_param4 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param4]) ,LOG_param5 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param5]) ,LOG_param6 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param6]) ,LOG_param7 = j.[LOG_param7] ,LOG_param8 = CAST(j.[LOG_param8] AS INT) ,LOG_param9 = CAST(j.[LOG_param9] AS SMALLINT) FROM (SELECT max(case when name='LOG_param1' then value else null end) as [LOG_param1], max(case when name='LOG_param2' then value else null end) as [LOG_param2], max(case when name='LOG_param3' then value else null end) as [LOG_param3], max(case when name='LOG_param4' then value else null end) as [LOG_param4], max(case when name='LOG_param5' then value else null end) as [LOG_param5], max(case when name='LOG_param6' then value else null end) as [LOG_param6], max(case when name='LOG_param7' then value else null end) as [LOG_param7], max(case when name='LOG_param8' then value else null end) as [LOG_param8], max(case when name='LOG_param9' then value else null end) as [LOG_param9] FROM temp.parseJSON(User_LOG.LOG_PARAMETERS) /* I want to reference the LOG_PARAMETERS column here */ ) j 

Je mets à jour toutes les colonnes param d'une sous-requête dans laquelle j'extrais les parameters Json. Je dois passer la colonne LOG_PARAMETERS à la fonction dans la sous-requête mais LOG_PARAMETERS cette erreur:

Msg 4104, niveau 16, état 1, ligne 1 L'identificateur en plusieurs parties "User_LOG.LOG_PARAMETERS" n'a pas pu être lié.

Je ne suis même pas sûr que cela soit possible ou non. Existe-t-il un moyen d'get cette mise à jour?

Utilisez APPLIQUER, sorte de

 UPDATE User_LOG SET LOG_param1 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param1]) ,LOG_param2 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param2]) ,LOG_param3 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param3]) ,LOG_param4 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param4]) ,LOG_param5 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param5]) ,LOG_param6 = CONVERT(UNIQUEIDENTIFIER, j.[LOG_param6]) ,LOG_param7 = j.[LOG_param7] ,LOG_param8 = CAST(j.[LOG_param8] AS INT) ,LOG_param9 = CAST(j.[LOG_param9] AS SMALLINT) FROM User_LOG CROSS APPLY (SELECT max(case when name='LOG_param1' then Ssortingngvalue else null end) as [LOG_param1], max(case when name='LOG_param2' then Ssortingngvalue else null end) as [LOG_param2], max(case when name='LOG_param3' then Ssortingngvalue else null end) as [LOG_param3], max(case when name='LOG_param4' then Ssortingngvalue else null end) as [LOG_param4], max(case when name='LOG_param5' then Ssortingngvalue else null end) as [LOG_param5], max(case when name='LOG_param6' then Ssortingngvalue else null end) as [LOG_param6], max(case when name='LOG_param7' then Ssortingngvalue else null end) as [LOG_param7], max(case when name='LOG_param8' then Ssortingngvalue else null end) as [LOG_param8], max(case when name='LOG_param9' then Ssortingngvalue else null end) as [LOG_param9] FROM parseJSON(LOG_PARAMETERS) /* I want to reference the LOG_PARAMETERS column here */ ) j;