SQL Error while upgrading a module

Jeroen de Kort asked on October 21, 2024 15:12

I'm trying to upgrade a module. When I do so I'm confronted with the following sql error.

Query:

DECLARE @NewPrefix VARCHAR(450);
DECLARE @OldLevel INT;
DECLARE @NewLevel INT;
SET @NewPrefix = (SELECT TOP 1 [ElementIDPath] FROM CMS_UIElement WHERE [ElementID] = 4793); IF (@NewPrefix = '/')SET @NewPrefix = '';
SET @OldLevel = (SELECT TOP 1 [ElementLevel] FROM CMS_UIElement WHERE [ElementID] = 4808);
SET @NewLevel = (SELECT TOP 1 [ElementLevel] FROM CMS_UIElement WHERE [ElementID] = 4793);

-- Update level

IF @UpdateLevel = 1 UPDATE CMS_UIElement SET [ElementLevel] = [ElementLevel] - @OldLevel + ISNULL(@NewLevel, -1) + 1 WHERE [ElementIDPath] LIKE '/00002824/00001166/00002152/00004789/00004790/%' ##SITEWHERECONDITION##

-- Update path

UPDATE CMS_UIElement SET [ElementIDPath] = ISNULL(@NewPrefix, '') + '/' + '00004808' + SUBSTRING([ElementIDPath], LEN('/00002824/00001166/00002152/00004789/00004790/'), LEN([ElementIDPath])) WHERE [ElementIDPath] LIKE '/00002824/00001166/00002152/00004789/00004790/%' ##SITEWHERECONDITION##

Caused exception:

Incorrect syntax near '##SITEWHERECONDITION##'.
Incorrect syntax near '##SITEWHERECONDITION##'.

For as far as I'm aware module can only be created (and therefore imported) on the global level. So I don't see where the should be a site where condition. Also I asssume that ##SITEWHERECONDITION## needed to be replaced by some condition, but it has not.

Does anyone have an idea for a solution?

Recent Answers


Laura Frese answered on November 5, 2024 21:58

You can delete ##SITEWHERECONDITION## from your query. its only needed if you want to update it on a specific site only. Its where you might want to add something like "WHERE SITEID=1"

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.